Blastradius Posted February 20, 2007 Share Posted February 20, 2007 I have used the TCP method of connecting for while now, which works fine for a single user, however thats where my problem comes in. I have no idea how to set a script up so it can support multiple users.. is it even possible? It should be somehow, i've looked at UDP too but that really didnt help me out either. Say for example i want a hundered users to connect to the 'server' and do something with it, how would i go about doing that? Thanks for the help.. Client/Server Code ============================================== Client ('messages' are set by hotkey which works fine): expandcollapse popup; Server Connection ;============================================== $serverIP = InputBox( "Server IP", "Please insert the IP of the server to connect with." ) $serverPort = InputBox( "Server Port", "Please insert the port of the server to connect with." ) ; Global Used Variable ;============================================== $isActive = 1 $isMessage = -1 ; Safe checking the required port ;============================================== If StringLen( $serverPort ) == 0 OR StringIsAlNum( $serverPort ) == 0 Then $serverPort = "22000" EndIf ; Start The TCP Services ;============================================== TCPStartup() ; Create a Connected Socket ;============================================== $clientStream = TCPConnect( $serverIP, $serverPort ) If @error OR $clientStream = -1 Then MsgBox( 4096, "DoH!", "Server connection failed!" ) Exit EndIf ; Look for / send keys to the server ;============================================== While $isActive If $isMessage <> -1 Then TCPSend ( $clientStream, $isMessage ) $isMessage = -1 EndIf Sleep( 50 ) Wend ; Close the TCP Services (if need do) ;============================================== TCPShutDown() Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 20, 2007 Moderators Share Posted February 20, 2007 I believe this one does that:http://www.autoitscript.com/forum/index.ph...st&p=134496 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Blastradius Posted February 20, 2007 Author Share Posted February 20, 2007 Im surpised i didnt find that one Anyway thanks for it, but this script leaves me with one question.. Where does $Data = "~bye" come from? Is it automaticly send when a socket closes? Link to comment Share on other sites More sharing options...
Snarg Posted February 20, 2007 Share Posted February 20, 2007 Where does $Data = "~bye" come from? Is it automaticly send when a socket closes?It comes from the client, probably sent when the client shuts down or disconnects. A little reading goes a long way. Post count means nothing. Link to comment Share on other sites More sharing options...
jvanegmond Posted February 20, 2007 Share Posted February 20, 2007 Im surpised i didnt find that one Anyway thanks for it, but this script leaves me with one question..Where does $Data = "~bye" come from? Is it automaticly send when a socket closes?I remember someone asked that question a long long time ago. ~bye is sent by the client to indicate that it wants to close the connection, then the server automatically closes the connection. You can remove this whole bit with ~bye, because in AutoIt both client and server can close a connection. Just remember to trap @error from a TCPRecv() function, to know if someone disconnected or not. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Blastradius Posted February 21, 2007 Author Share Posted February 21, 2007 Allright, i used to did it that way so i wondered what the difference was anyway. Thanks xD 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