Sign in to use Parts List
New to element14? Register
Sign in to view your Bookmarks
You must be registered with an element14 username before continuing
As a member, you'll get access to:
Find out more about element14 community
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?
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.
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
print "closing shell..."
TCP client: To messy to put here.
I think I have solved my own problem...
I have used a massive while loop over the whole thing so that when the message = <nothing>, then the connection resets.
Retrieving data ...