1 Reply Latest reply on Nov 25, 2012 12:46 AM by wallarug

    Python socket server lost connection - restart:


      I am using python socket module for a TCP client/server set-up.

      I have a question:

      How can I send some sort of message to the client or server that the connection has been lost?

      and then:

      how can I get the connection back up again, knowing that the connection has been lost?

      I can answer the second question if someone can tell me how to return that a connection has been lost.

      TCP server:

      import sys

      import socket               # Import socket module

      s = socket.socket()         # Create a socket object

      host = 'localhost' # Get local machine name

      port = 9999                # Reserve a port for your service.




      print 'Server started!'

      print 'Waiting for clients...'


         s.bind((host, port))        # Bind to the port

         s.listen(5)                 # Now wait for client connection.

         c, addr = s.accept()     # Establish connection with client.

         print 'Got connection from', addr



      except KeyboardInterrupt:

         print "closing shell..."


         sys.exit("Closing Application...")[/code]



      TCP client: To messy to put here.



      Any help?