Jump to content

TCP/IP Connections


 Share

Recommended Posts

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

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

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


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


jpm
            
            
                Posted 
                
            
        
    
    
        


jpm
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Developers
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 10.3k
                            
                                
                            
                        
                        
                            
                                
                                    
                                        
                                        24
                                
                                    
                                
                            
                        
                    
                
            
            
                

    
    
        
a Real GUI/debug lover
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            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 :(
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...