Errno 10061 in python, I don't know what to do

I learned about sockets in python. When I tried to program the script sockets on the same computer it worked, but when I tried to program the script sockets with two different computers and open a socket with a connection it didn't work.

One computer (server):

import socket

s = socket.socket()

host = socket.gethostname()
port = 1234
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()

      

Second computer (client):

import socket

s = socket.socket()

host = raw_input("The ip you want to connect to: ")
port = 1234

s.connect((host, port))
print s.recv(1024)

      

Mistake:

socket.error: [Errno 10061]

      

What is the problem with scripts? Why doesn't it work?

+3


source to share


1 answer


Errno 10061:

This means that the server you are trying to connect to is not waiting for it.

  • Make sure the port number is open.
  • Try to kill all python processes and start the server again.

Update



Instead

host = socket.gethostname()

      

using

host = ""

      

+4


source







All Articles