Hello, I've a TCP connection (simple TWSocket, only one PC may connect) and want to implement some keep-alive now. The rest of the application seems to work well, but the keepalive killed my whole day now without much success.
Currently I'm doing this in the OnSessionAvailable of the server: Where a is a TWScket descendant: if not assigned(a) then begin a:=MyTWSocket.Create; a.dup(...); // here get's the connection assigned end; That works. My protocol is now such that the client sets up a timer when he connects to the sever which will send every few seconds a dummy request which the server simply has to echo back. The server also has a timer set up in the OnSessionConnected method which will check wether a keepalive request has been received within the time or not. If not he triggers the following: a.abort; FreeAndNil(a); The other socket of the server still is in the listening state where I've left it since he was told to listen. The client will notice it in its own timer because his keepalive requests won't be answered anymore. If the client detects this he starts another timer which tries every second to establish a connection to the same adress. This sheme works 1-2 times (pulling out the cable) but then it doesn't work anymore because windows sets these sockets to waiting or something like this. What's wrong here? Is the abort and FreeAndNil bad? What I like to accomplish is simple: be able to unplug the cable and replug it a few seconds later and the connection should be reestablished within a few seconds. If the server is already sending data to the client (which got lost before, I don't really detect and handle this yet) I'd like to receive just the data from the server from the point on the connection is okay again. And I'd like to be able to repeat this, means plug out the cable again and after replugging it the connection shoudl resume etc. Greetings Maarkus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be