python - Socket cannot connect -


question

how can fix program make socket connected? also, please test code. have seen many answers this, none have worked.

thank help.

background

for while, have worked on program send messages on lan. have been trying work on integrating knowledge of gui , of sockets in project. but, no matter seem do, socket has been unable stay connected.

i have asked many questions this, no matter have not been able discover correct fix. believe fault - self taught , have perhaps not asked correct questions. time, have chosen blanket statement; please pardon lack of finesse, seems best way of now. here link code on paste bin. have included problematic parts below.

error message

('localhost', 1234) socket created socket bind complete socket listening exception in tkinter callback traceback (most recent call last):   file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-tk/tkinter.py", line 1410, in __call__     return self.func(*args)   file "/volumes/xxmbabanexx's usb/python programs/sockets/im project/server/functions/simple server.py", line 148, in <lambda>     command = lambda: send_msg(s,message))   file "/volumes/xxmbabanexx's usb/python programs/sockets/im project/server/functions/simple server.py", line 82, in send_msg     conn.sendall(my_message)   file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/socket.py", line 224, in meth     return getattr(self._sock,name)(*args) error: [errno 57] socket not connected 

relevant code

as error message says send_msg function having issues, have decided include below.

def send_msg(conn, message):      """send messages"""     #send data remote server     my_message = message.get("0.0", end)        #set whole string     conn.sendall(my_message) 

thank of help. issue has been bothering me months, , refuse let go.

you trying run before know how crawl.

throw away tk , threading. @ socketserver examples , run them. work can basic socket understanding appear lack.

just know, stackoverflow people quite unlikely go @ pastebin code. did @ , redundant , confusing.


Comments