roy Posted June 13, 2005 Share Posted June 13, 2005 Hi to all, there is someone that has already played with TCP** functions? I'm trying to develop a simple Echo Server that accept multiple client connections and echoes back data read from each client. I'm not able to find a method to detect when the client closes the connection. The TCPRecv function on a client closed connection doesn't report any error. Is this a Bug or there is a way to do it? Thank you in advance. I'm using beta version 3.1.45. Link to comment Share on other sites More sharing options...
roy Posted June 13, 2005 Author Share Posted June 13, 2005 Larry, I just tried your solution (sending an empty string) but without success. It seems that TCPSend doesn't perform any action, peraps because there is nothing to send. Link to comment Share on other sites More sharing options...
kristoff Posted June 13, 2005 Share Posted June 13, 2005 Hi,This is what I wrote few mns ago fro myself.Still buggy at the error managing when host isn't resolved.expandcollapse popup$dest="totot"$port = "23"DLLCall( "AU3Xtra.dll", "int", "TCPStartUp" )$var = DLLCall( "AU3Xtra.dll", "int", "TCPNameToIP", "str", $dest, "str", "" )if @error < 0 then MsgBox( 4096, " C PAS BON ", $dest&" IS NOT RESOLVED" )elseMsgBox( 4096, " TOUT VA BIEN ", $dest & " IS RESOLVED TO : " &$var[2] )Endif$socket = DLLCall( "AU3Xtra.dll", "int", "TCPConnect", "str", $var[2], "int", $port )If @error Or $socket[0] < 0 Then Msgbox(0,'PORT STATUS',"NOT OK" ) else Msgbox(0,'PORT STATUS', "OK" ) Endif;int TCPShutDown()DLLCall( "AU3Xtra.dll", "int", "TCPShutDown" )Hope it drive you on the good waySchuss/cheers/salut Link to comment Share on other sites More sharing options... jpm Posted June 13, 2005 jpm Developers 10.4k 24 a Real GUI/debug lover Share Posted June 13, 2005 Hi,This is what I wrote few mns ago fro myself.Still buggy at the error managing when host isn't resolved.$dest="totot"$port = "23"DLLCall( "AU3Xtra.dll", "int", "TCPStartUp" )$var = DLLCall( "AU3Xtra.dll", "int", "TCPNameToIP", "str", $dest, "str", "" )if @error < 0 then MsgBox( 4096, " C PAS BON ", $dest&" IS NOT RESOLVED" )elseMsgBox( 4096, " TOUT VA BIEN ", $dest & " IS RESOLVED TO : " &$var[2] )Endif$socket = DLLCall( "AU3Xtra.dll", "int", "TCPConnect", "str", $var[2], "int", $port )If @error Or $socket[0] < 0 Then Msgbox(0,'PORT STATUS',"NOT OK" ) else Msgbox(0,'PORT STATUS', "OK" ) Endif;int TCPShutDown()DLLCall( "AU3Xtra.dll", "int", "TCPShutDown" )Hope it drive you on the good waySchuss/cheers/salut[post="85671"]<{POST_SNAPBACK}>[/post]It could have been good to write the code withnthe beta TCP functions Link to comment Share on other sites More sharing options...
kristoff Posted June 14, 2005 Share Posted June 14, 2005 Hi, For sure, I took the code wrote from Larr example. I'm stuck with the error return code, else it works fine and fulfill my expectations Link to comment Share on other sites More sharing options...
Fur Posted June 17, 2005 Share Posted June 17, 2005 If recv() on the server returns 0, then the client has closed its connection. You can pass MSG_PEEK to recv() if you just want to check this without actually reading anything from the socket. Link to comment Share on other sites More sharing options...
Recommended Posts
kristoff
Hi,
For sure, I took the code wrote from Larr example.
I'm stuck with the error return code, else it works fine and fulfill my expectations
Link to comment
Share on other sites
Fur
If recv() on the server returns 0, then the client has closed its connection.
You can pass MSG_PEEK to recv() if you just want to check this without actually reading anything from the socket.
Link to comment
Share on other sites