erifash Posted June 28, 2005 Share Posted June 28, 2005 My host script sends the string "~~accepted" to the client script if the user presses "yes" to accept the client's connection to the host. If the user presses "no" to deny the connection from the client to the host, the host will send the string "~~rejected" to the client. If the client detects that the host accepted the connection it will continue with normal operations, but if it detected the host rejected the connection it will exit. The problem is that the client is getting stuck in one of the while loops. Here is the code I have: Part of client script ; Wait For Connection ;============================================== $connection = -1 While $connection = -1 Sleep(10) $connection = TCPAccept($socket) Wend $recv = "" While $recv <> "~~accepted" Sleep(10) $recv = TCPRecv($socket, $n_maxrecv) If $recv = "~~rejected" Then GUICtrlSetData($edit, "~~Connection Rejected" & @CRLF, 1) WinSetTitle($GOOEY,"","Connection Rejected") Sleep(2000) $failed = 1 Exit EndIf Wend GUICtrlSetData($edit, "~~Connection Accepted" & @CRLF, 1) WinSetTitle($GOOEY,"","Client - Host Connected") I hope that someone will be able to help me! My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
roy Posted June 29, 2005 Share Posted June 29, 2005 See this post for tcp client/server sample programs.TCP Echo ServerRoy Link to comment Share on other sites More sharing options...
erifash Posted June 29, 2005 Author Share Posted June 29, 2005 See this post for tcp client/server sample programs.TCP Echo ServerRoy <{POST_SNAPBACK}>I saw that a while back. Good scripting, but bad for someone (like me) that can't figure out how to even fix a small part of a script. Thanks for the help though, it was very appreciated!This code should work though but it doesn't. Any help? My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Fur Posted June 29, 2005 Share Posted June 29, 2005 Well I haven't used those TCP functions in the beta, but I suspect if the socket is broken, TCPRecv() is going to return 0 or "" or something else besides "~~rejected" I'd add a case to check for that. Link to comment Share on other sites More sharing options...
erifash Posted July 1, 2005 Author Share Posted July 1, 2005 Well I haven't used those TCP functions in the beta, but I suspect if the socket is broken, TCPRecv() is going to return 0 or "" or something else besides "~~rejected" I'd add a case to check for that.<{POST_SNAPBACK}>Exactly why I haveWhile $recv <> "~~accepted"because "" <> "~~accepted" and 0 <> "~accepted". Also, the script exits if TCPConnect fails (returns -1), which is basically saying, "if the socket is broken then exit". Another thing with the "~~rejected" string: The host sends that string to the client based on if the host accepted or rejected the clients connection. It is not returned by TCPRecv() if it fails.TCPRecv:Return ValueSuccess: Returns string send by the connected socket. Failure: Returns "" and set @error according to Windows API WSAGetError return.It returns a blank string "" if it fails. A blank string is not equal to "~~accepted" or "~~rejected" so it will keep on looping until it gets one of those strings from the host. My problem is that it keeps on looping no matter what.Thanks for the replys. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
erifash Posted July 1, 2005 Author Share Posted July 1, 2005 The ToolTip didn't display at all so that must mean that it is hanging up in the first loop. I know the syntax is right for the first loop as TCPAccept returns -1 if there is no connection. That might mean there is a problem with the host script.Here are my two scripts:Copy_of_TCPchat_host.au3Copy_of_TCPchat_client.au3 My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver 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