How do you close a client TCp socket?

If I have opened a client TCP socket using ed_SocketTCPStart (with Listen=0) how can I close it?
There is the ed_SocketTCPStart function, but that says it is only for stopping a server socket.
At the moment I just stop the IP connection and disconnect from GPRS, but that doesn’t seem to tell my server that the socket has gone, so it thinks the socket is still open.

To stop it just send nothing:

x = ed_SendDataExt( "", 0, TRUE, ED_ID_TCPSOCKET_1 );

Best Regards,

Hi charlesoram,
I agree with the answer provided by “jan”.
Please note that the ed_SocketLTCPStop () function (used to close server socket) can be used to close only listening TCP server sockets. Listening server sockets are the one which have not established any connection with a client and are simply listening for clients. Once, the server TCP socket establishes a socket connection with a client it becomes an “Active Connection” and this can now be closed using ed_SendDataExt( “”, 0, TRUE, ED_ID_TCPSOCKET_1 ); statement (same statement that is used to close a client socket).

Best Regards,

Thanks Jan and OpenAT_Fan for your quick answers.

I have found that if I have a 5s delay after closing the socket (as described by Jan) before I disconnect from IP and detach fom GPRS, then the server has the socket closed properly. I guess the IP network needs to stay up for long enough for the TCP RST to get through.

  • Charles

my Question is when should I close my socket ?

Indeed I try to do a request to a googlepage and I got this :
httpPost_ResponseCbk Event = 107 - id = 1
httpPost_DataRequest Event id = 1, MaxLen = 536
httpPost_DataRequest Event id = 1, MaxLen = 411
httpPost_DataHnd Event id = 1 DataLen = 1430
httpPost_DataHnd Event id = 1 DataLen = 25

And later the server close the connection (after a timeout I guess)
httpPost_DataHnd Event id = 1 DataLen = 0
httpPost_ResponseCbk Event = 5 - id = 1

I’d like to close myself the connection in order to win the timeout delay …
but I don’t see when I can do that ???

Any Idea ?


The answer is to check the “Content-Length:” in the http header response :wink: