Drchubby Posted December 10, 2008 Share Posted December 10, 2008 Are multiple tcp connections possible to one port on the server? And can a server coded in autoit handle multiple connections? thanks Link to comment Share on other sites More sharing options...
Andreik Posted December 10, 2008 Share Posted December 10, 2008 Are multiple tcp connections possible to one port on the server? And can a server coded in autoit handle multiple connections? thanks Yes, I write an example (not tested): SERVER HotKeySet("{ESC}","Quit"); Press ESC to quit Global $CURRENT_SOCKET = 0 Global $CONNECTED_SOCKET[16] Global $TCP_SERVER $TCP = TCPStartup() If $TCP = 0 Then MsgBox(0, "Error", "Unable to startup TCP Services!") Exit EndIf $TCP_SERVER = TCPListen(@IPAddress1,1777,16) If $TCP_SERVER = -1 Then MsgBox(0, "ERROR", "Unable to start listening on port 1777") Exit EndIf While 1 $CONNECTED_SOCKET[$CURRENT_SOCKET] = TCPAccept($TCP_SERVER) If $CONNECTED_SOCKET[$CURRENT_SOCKET] <> -1 Then $CURRENT_SOCKET += 1 EndIf For $INDEX = 0 To 15 $RECV = TCPRecv($CONNECTED_SOCKET[$INDEX],512) If $RECV <> "" Then MsgBox(0,"Socket#" & $INDEX,"DATA:" & $RECV) Next Sleep(20) WEnd Func Quit() TCPCloseSocket($TCP_SERVER) TCPShutdown() Exit EndFunc CLIENT - Change @IPAddress1 with Server IP HotKeySet("{ESC}","Quit"); Press ESC to quit HotKeySet("#s","SendCom") $PORT = 1777 $IP = @IPAddress1 $TCP = TCPStartup() If $TCP = 0 Then MsgBox(0, "Error", "Unable to startup TCP Services!") Exit EndIf $TCP_CLIENT = TCPConnect($IP,$PORT) If $TCP_CLIENT = -1 Then MsgBox(0, "ERROR", "Unable to connect "& $IP & " on port 1777") Exit EndIf While 1 Sleep(50) WEnd Func SendCom() TCPSend($TCP_CLIENT,"THIS IS A TEST") EndFunc Func Quit() TCPCloseSocket($TCP_CLIENT) TCPShutdown() Exit EndFunc When the words fail... music speaks. 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