Login  
Search All Forums
Dart Home | PowerTCP Winsock for ActiveX | Custom Development Reply | PowerTCP Winsock for ActiveX Topics | Forums   
AuthorForum: PowerTCP Winsock for ActiveX
Topic: How to close connection gracefully?
lassekj
laskje@gnotometrics.dk

From: Odense, Denmark
Posts: 3
Member Since: 04/26/04
posted July 21, 2004 7:21 AM

Hi.

We have problems closing a tcp connection gracefully. The situation is like this:

We have build our own server application using your winsock tool. In this server a daemon control is listening for incoming connections. When a connection is made it passes the socket id onto a TCP control that handles the communication.

In the other end of the line we have another server that is sending messages to our server. It only creates one connection which it then uses to send data through.

In our server we have to be able to close this connection, if an internal server error occurs and then re-open it again when the server is ready to receive again. But this is where we have a problem, because we seem to lose a message sometimes when we call Close() on the tcp connection.
When our server wants to close the connection it waits until the ReceiveBufferCount is zero, and then it closes the connection. The other server now get a exception because we have closed the connection and the resends the message when we establish a connection again. But unfortunately we do not receive all message everytime. The server that sends is a thourghly tested server application called Rhapsody by 'Orion Health' so we have no reason to beleive that it doesn´t resent the message. The problem must lie within the way we close the connection.

So my question is - how should we handle the situation in the cose when we close the connection?

The TCP control is using the TCP_Receive event to be notified when data is available, so timeout is 0. And as mentioned earlier we only close the connection when receivebuffercount is 0.

Thanks in advance
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted July 22, 2004 10:34 AM

Hi,
If you use the Trace method to create a log of the data coming in, does it show data received that is not available when Tcp.Receive is called?

Have you tried setting a timeout value prior to the Close call?
When Tcp.Close is called with timeout, it actually goes into a Closing state, during which time it finishes receiving any available data before going to the Closed state.
Perhaps that would help.

-ken

Reply | PowerTCP Winsock for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX