I have a server and some number of clients any of which may or may not be present. If the server is not available then the functionality of the server is not available but the clients have functionality of their own.
When the sever starts it opens a listening socket... wserverSocket->Close(); wserverSocket->Proto = "tcp"; wserverSocket->Port = "25123"; wserverSocket->Addr = "0.0.0.0"; wserverSocket->ClientClass = __classid(TMyClient); wserverSocket->Listen(); When the clients start they repeatedly try to connect. If the server is available they connect immediately, otherwise they connect if and when the server becomes available. This is done by posting a message... //--------------------------------------------------------------------------- void __fastcall Tdata::wclientSocketSessionClosed(TObject *Sender,WORD Error) { connected = false; PostMessage(startForm->Handle,WM_RECONNECT,0,0); } That causes a this handler to be called.... //--------------------------------------------------------------------------- void __fastcall TstartForm::WMReconnect(TMessage Message) { wclientSocket->Shutdown(2); wclientSocket->Close(); wclientSocket->Port = "25123"; wclientSocket->Proto = "tcp"; wclientSocket->Addr = data->host; wclientSocket->Connect(); Sleep(100); } if the connection is successful wclientSocketSessionClosed(...) doesn't happen anymore and the client is connected. The problem is that until a connection is made, when an attempt to connect happens the state wclientSocketChangeState(...) reports wsConnected even though the server is not there and no connection actually occurred. My question is how can I have a scheme were the clients and server can connect when conditions are right for them to do so and have a definite knowledge in the client that it is connected rather than a connected state that is toggling? There's got to be a better way to do this, any help is appreciated. David -- 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