Excalibur Posted June 15, 2006 Share Posted June 15, 2006 I am trying to create a very simple chat client/server, and I have written the server code as follows: expandcollapse popup; GUI CODE ABOVE THIS; GUISetState(@SW_SHOW); Global $ServerSocket; Global $SocketCreated = "false"; Global $IP = "127.0.0.1"; _GetIP() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $StartServerButton systemReport("Starting Server..."); startServerSocket(GUICtrlRead($PortInput)); Case $msg = $GUI_EVENT_DROPPED systemReport("Drag & Drop Detected"); Case Else ;;;;;;; EndSelect if ( $SocketCreated == "true" ) Then ;systemReport("Checking for Connections"); $ConnectedSocket = TCPAccept($ServerSocket); If $ConnectedSocket >= 0 Then systemReport("Client Connected"); TCPCloseSocket($ConnectedSocket); EndIf EndIf WEnd Func startServerSocket($port) ;if ( $SocketCreated == "false" ) Then TCPStartUp(); TCPListen("127.0.0.1", 3127, 10 ); If $ServerSocket = -1 Then systemReport("Cannont Listen on port[" & $port & "] ."); Else systemReport("Server Started Successfully on port[" & $port & "]"); $SocketCreated = "true"; EndIf ;Else ; systemReport("Server Already Started"); ;EndIf EndFunc Func systemReport($Message) GUICtrlSetData($ConnectedUserBox, "<System> " & $Message & @CRLF, "whatever"); EndFunc The server always responds "Server Started Successfully on port 3127", yet my firewall never goes off asking if i want to allow it access, and my dummie client (just connects) fails to connect to it. I have tried it using 127.0.0.1 and my outside IP address. Also, I have read the help file and I am not quite sure how I would sustain mutiple connections at the same time. Perhaps this outside of the scope of the AutoIt Language. Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein Link to comment Share on other sites More sharing options...
Helge Posted June 16, 2006 Share Posted June 16, 2006 Also, I have read the help file and I am not quite sure how I would sustain mutipleconnections at the same time. Perhaps this outside of the scope of the AutoIt Language.For this you could check out my http://www.autoitscript.com/fileman/users/Helge/udfs.htm#tcpserver-udfs, which tries to make this easier...Only thing missing in that collection, as far as I can see, is a UDF which forwardsdata from one client to the other clients... haven't decided exactly how I shoulddo this yet... The other UDFs however should be ok, I guess Link to comment Share on other sites More sharing options...
themax90 Posted June 16, 2006 Share Posted June 16, 2006 For other things TCP, you can check my signature for many links. 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