Sign in to follow this  
Followers 0
roy

TCP/IP Connections

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
jpm   

    
        
    
             37
    
        
    

        
            
                a Real GUI/debug lover
            
            

            
                

    
        
    

            
            Developers
            
                
            
            
                

    
        
    
             37
    
        
    

                9,715 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #4 · 
            Posted 
            
            
            
        
    

    


            
        
            
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" )

else

MsgBox( 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 way

Schuss/cheers/salut

[post="85671"]<{POST_SNAPBACK}>[/post]

It could have been good to write the code withnthe beta TCP functions :(

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0