Tuesday, 15 July 2014

How to fix Error 61 (Mac) and Error 10061(Windows) using Python 2.7.3 -



How to fix Error 61 (Mac) and Error 10061(Windows) using Python 2.7.3 -

i attempting create basic lan socket server, works correctly when utilize both client , server on same computer. when effort utilize client , server on 2 computers (mac , windows) connection consistently refused on client side. here error got on mac:

traceback (most recent phone call last): file "/users/*****/desktop/client v2.py", line 31, in <module> s.connect((host, port)) file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/socket.py", line 224, in meth homecoming getattr(self._sock,name)(*args) error: [errno 61] connection refused

on windows had same error, number different. have turned off windows firewall both incoming , outgoing connections, , confused actual issue is. here code had ports:

client

#get host , port info connect host = 'localhost' port = input ("what port number?")

i not sure if these lines necessary, perhaps root cause of problem:

try: remote_ip = socket.gethostbyname(host) except socket.gaierror: #could not resolve print "hostname not resolved. exiting" sys.exit()

and finally, actual code connects. (i called socket s) s.connect((host, port))

server

host = 'localhost' #symbolic name meaning available interfaces port = input ("enter port number (1 - 10,000)") s = socket.socket(socket.af_inet, socket.sock_stream) print "socket created" try: s.bind((host, port)) except socket.error, msg: print "bind failed. error code : " + str(msg[0]) + " message " + str(msg[1]) sys.exit() print "socket bind complete" s.listen(10) print "socket listening"

i have done silly, can please tell me error (or if possible cross-os). posted here, no 1 responded. have several other questions there, , great if effort reply them.

host = 'localhost' #symbolic name meaning available interfaces

doesn't mean "all available interfaces" local machine via special interface visible programs running on same computer.

host = '0.0.0.0' #symbolic name meaning available interfaces

does mean available network interfaces. of course of study can bind specific network interface, in case come in ip address in field.

python windows osx sockets

No comments:

Post a Comment