svennie Posted November 11, 2005 Share Posted November 11, 2005 Like when i send a message "hello" to a server using TCPSend it have to wait until something was sent and then go further receiving and sending.I already tried this:While 1 If TCPRecv($f_Connect,1024) <> "" Then ExitLoop WEndAnd this:Do Until TCPRecv($f_Connect,1024) <> ""And some other ways.It's sure it responses.Since when i use Sleep(1000) it just receive it.Example of what i am doing:- Send "hello"- Wait until response received and ignore it (not immediatly return, because then a message will be send when it's still responsing on my message before)- Send "hello again"- Wait until response received ... etc (same as above)- Send "code"- Wait until response, receive it fully and then he cacluates what to do with it etc.So wait until response is the problem . Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF Link to comment Share on other sites More sharing options...
jpm Posted November 11, 2005 Share Posted November 11, 2005 did you read the TCPSend and TCPRecv examples which implement the Client and Server? Link to comment Share on other sites More sharing options...
themax90 Posted November 11, 2005 Share Posted November 11, 2005 (edited) Reciever Dim $Port = 8000 TCPStartup $MainSocket = TCPListen(@IPAddress1, $Port) While 1 $Recv = TCPRecv($ConnectedSocket) If $Recv = "" Then ExitLoop EndIf If $ConnectedSocket = -1 Then $ConnectedSocket = TCPAccept(MainSocket) EndIf WEnd MsgBox(0, "Recieved Message!", "You received: " & $Recv) ; Rest of Code TCPCloseSocket($ConnectedSocket) TCPCloseSocket($MainSocket) TCPShutdown() Sender Dim $IP = @IpAddress1, $Port = 8000 TCPStartup $ConnectedSocket = TCPConnect($IpAddress, $Port) TCPSend($ConnectedSocket, "Hello World!") TCPCloseSocket($ConnectedSocket) TCPShutdown() Edited November 11, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
svennie Posted November 11, 2005 Author Share Posted November 11, 2005 RecieverDim $Port = 8000 TCPStartup $MainSocket = TCPListen(@IPAddress1, $Port) While 1 $Recv = TCPRecv($ConnectedSocket) If $Recv = "" Then ExitLoop EndIf If $ConnectedSocket = -1 Then $ConnectedSocket = TCPAccept(MainSocket) EndIf WEnd MsgBox(0, "Recieved Message!", "You received: " & $Recv) ; Rest of Code TCPCloseSocket($ConnectedSocket) TCPCloseSocket($MainSocket) TCPShutdown()SenderDim $IP = @IpAddress1, $Port = 8000 TCPStartup $ConnectedSocket = TCPConnect($IpAddress, $Port) TCPSend($ConnectedSocket, "Hello World!") TCPCloseSocket($ConnectedSocket) TCPShutdown()No, that is not what i mean.It just must pause the script until something is received from te server. Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF Link to comment Share on other sites More sharing options...
themax90 Posted November 11, 2005 Share Posted November 11, 2005 (edited) Reciever Dim $Port = 8000 TCPStartup $MainSocket = TCPListen(@IPAddress1, $Port) While 1 $Recv = TCPRecv($ConnectedSocket) If $Recv = "" Then ; Something Was Received EndIf If $ConnectedSocket = -1 Then $ConnectedSocket = TCPAccept(MainSocket) EndIf WEnd TCPCloseSocket($ConnectedSocket) TCPCloseSocket($MainSocket) TCPShutdown() Sender Dim $IP = @IpAddress1, $Port = 8000 TCPStartup $ConnectedSocket = TCPConnect($IpAddress, $Port) TCPSend($ConnectedSocket, "Hello World!") TCPCloseSocket($ConnectedSocket) TCPShutdown() The Receiver script WILL NOT do anything unless something is recieved in the first place. Edited November 11, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
svennie Posted November 12, 2005 Author Share Posted November 12, 2005 Dim $Port = 8000 TCPStartup $MainSocket = TCPListen(@IPAddress1, $Port) $ConnectedSocket = -1 While $ConnectedSocket = -1 $ConnectedSocket = TCPAccept(MainSocket) WEnd While 1 $Recv = TCPRecv($ConnectedSocket) If $Recv <> "" Then ExitLoop WEnd TCPCloseSocket($ConnectedSocket) TCPCloseSocket($MainSocket) TCPShutdown()Thanks it works! Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now