Skip to main content
Fix an obvious indetation error in code samle
Source Link
tdelaney
  • 77.9k
  • 6
  • 91
  • 129

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

 #!/usr/bin/python  import socket  s = socket.socket()  host = ''  port = 12345  s.bind((host, port))  s.listen(5)  while True:   c, addr = s.accept()   print 'Got connection from', addr   c.send('Thank you for connecting')   c.close() 

and the client.py:

 #!/usr/bin/python  import socket  s = socket.socket()  host = # here I put the ip of the server's laptop  port = 12345  s.connect((host, port))  print s.recv(1024)  s.close() 

What's wrong?

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

 #!/usr/bin/python  import socket  s = socket.socket()  host = ''  port = 12345  s.bind((host, port))  s.listen(5)  while True:   c, addr = s.accept()   print 'Got connection from', addr   c.send('Thank you for connecting')   c.close() 

and the client.py:

 #!/usr/bin/python  import socket  s = socket.socket()  host = # here I put the ip of the server's laptop  port = 12345  s.connect((host, port))  print s.recv(1024)  s.close() 

What's wrong?

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

#!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print 'Got connection from', addr c.send('Thank you for connecting') c.close() 

and the client.py:

#!/usr/bin/python import socket s = socket.socket() host = # here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

Fix an obvious indetation error in code samle
Source Link
tdelaney
  • 77.9k
  • 6
  • 91
  • 129

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

 #!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True:   c, addr = s.accept()   print 'Got connection from', addr   c.send('Thank you for connecting')   c.close() 

and the client.py:

 #!/usr/bin/python import socket s = socket.socket() host = //# here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

 #!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print 'Got connection from', addr c.send('Thank you for connecting') c.close() 

and the client.py:

 #!/usr/bin/python import socket s = socket.socket() host = //here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

 #!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True:   c, addr = s.accept()   print 'Got connection from', addr   c.send('Thank you for connecting')   c.close() 

and the client.py:

 #!/usr/bin/python import socket s = socket.socket() host = # here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

added 7 characters in body; edited title
Source Link
MatthewD
  • 6.8k
  • 5
  • 24
  • 44

python Python server client socket

I've tried to connect two computers with a socket in pythonPython and I don't know why it doesn't work.The The files are from internet and it compiles for me but without any results. The

The server.py:

 #!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print 'Got connection from', addr c.send('Thank you for connecting') c.close() 

and the client.py:

 #!/usr/bin/python import socket s = socket.socket() host = //here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

python server client socket

I've tried to connect two computers with a socket in python and I don't know why it doesn't work.The files are from internet and it compiles me but without any results. The server.py:

 #!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print 'Got connection from', addr c.send('Thank you for connecting') c.close() 

and the client.py:

 #!/usr/bin/python import socket s = socket.socket() host = //here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

Python server client socket

I've tried to connect two computers with a socket in Python and I don't know why it doesn't work. The files are from internet and it compiles for me but without any results.

The server.py:

 #!/usr/bin/python import socket s = socket.socket() host = '' port = 12345 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print 'Got connection from', addr c.send('Thank you for connecting') c.close() 

and the client.py:

 #!/usr/bin/python import socket s = socket.socket() host = //here I put the ip of the server's laptop port = 12345 s.connect((host, port)) print s.recv(1024) s.close() 

What's wrong?

Source Link
IleNea
  • 609
  • 1
  • 7
  • 21
Loading