Search the Community
Showing results for tags 'servers'.
458 downloadsA UDF to connect to IRC using TCP Functions, as well as perform actions once connected. Based on and Updated from Chip (McGod)'s original IRC code, which no longer works. Features: Heavyweight * Large feature set * Well Documented Examples Message formatting * Styles * Colors RFC1459 + RFC2812 Compliant * Able to handle moderately non-compliant servers * Works on IRCv3 although missing the features of it * Tested on various networks from Freenode to Rizon Helpful Premade Examples Files * Examples for almost every function * Premade CUI and GUI clients showing Ready for all users, beginner and up * Detailed Error Reporting to help pin-point problems * Thorough parameter checking to prevent accidental script crashes Support: Support for this UDF can be obtained in my Discord Server
Hi! If you liked my TCPServer UDF, you'll also like this one. Following the same principles, this TCPClient UDF helps you on handling multiple connections to different servers, and set actions depending on two events: OnReceive and OnDisconnect. It is also multi server (you can connect to many servers at once) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create a TCP application and don't want to deal with the TCP* functions. Also, it runs on background just firing events, it won't pause your script while waiting/receiving data, so you can do anything else (close and open connections, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired It is also very easy to use. See this examples: Example #1: Connecting to a basic server By running this (as soon as you open a basic server with Netcat) you will receive a message box telling you when the server closes the connection (the socket ID and his IP address are passed as parameter to your callback function) and also when the server sends something over the TCP socket (the data sent is passed as parameter). #cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv -l -p 8081 #ce #include "TCPClient.au3" ; First we set the callback functions for the two events (none of them is mandatory) _TCPClient_OnDisconnect("disconnect") _TCPClient_OnReceive("received") ; And a parameter _TCPClient_DebugMode(True) ; Finally we connect to the server at port 8081 at any interface _TCPClient_Connect('127.0.0.1', 8081) Func disconnect($iSocket, $sIP) MsgBox(0, "Server disconnected", "Server " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sPar) MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar) _TCPClient_Send($iSocket, "You wrote: " & $sData) _TCPClient_SetParam($iSocket, 'will write again') EndFunc ;==>received While 1 Sleep(100) WEndExample #2: Requesting a page from a HTTP server In this example, we run this code and it will get the response from a HTTP server. Of course, as we are requesting google.com index, it may just show a redirect page to a local (with country top-level domain) Google page or with some stuff on the URL. #include "TCPClient.au3" _TCPClient_OnReceive("received") _TCPClient_DebugMode(True) $iSocket = _TCPClient_Connect(TCPNameToIP('google.com'), 80) If @error Then Exit _TCPClient_Send($iSocket, "GET / HTTP/1.0" & @CRLF & @CRLF) Func received($iSocket, $sIP, $sData, $sParam) MsgBox(0, "Data received", $sData) _TCPClient_Disconnect($iSocket) EndFunc ;==>received While 1 Sleep(100) WEndExample #3: Command prompt bound to the socket after password requesting By running this example, we will be asked for a password, which is 123456 as we set on the script. If the password is correct, we will see the Command Prompt live-updated (try running a ping to some server, for example). #include "TCPClient.au3" #cs To test this example, execute a netcat server, running this commands: nc -vv -l -p 31337 #ce Global $Password = "123456" _TCPClient_OnReceive("receive") _TCPClient_OnDisconnect("disconnect") _TCPClient_DebugMode() Func receive($iSocket, $sIP, $sData, $mPar) If $mPar = "login" Then If $sData = $Password Then ; right password, let's change the parameter _TCPClient_SetParam($iSocket, "logged") ; and now bind _TCPClient_BindAppToSocket($iSocket, "cmd.exe") Else _TCPClient_Send($iSocket, "Wrong password. Try again: ") EndIf Else If $sData = "exit" Then ; unbinds _TCPClient_UnBindAppToSocket($iSocket) ; says bye _TCPClient_Send($iSocket, "See you") ; closes connection _TCPClient_Disconnect($iSocket) Else ; sends command directly to the process _TCPClient_SendToBound($iSocket, $sData) EndIf EndIf EndFunc Func disconnect($iSocket, $sIP) MsgBox(0, $iSocket, $sIP) EndFunc $iSocket = _TCPClient_Connect('127.0.0.1', '31337') If @error Then MsgBox(0, "", "could not connect. Error: " & @error) Exit EndIf ; Sets parameter to login, so we know what the server is doing _TCPClient_SetParam($iSocket, "login") _TCPClient_Send($iSocket, "Please enter password: ") While True Sleep(100) WEndThe limit is your imagination? Well, maybe. Functions list: _TCPClient_Connect($sSvr, $iPort) _TCPClient_Disconnect($iSocket) _TCPClient_SetParam($iSocket, $sPar) _TCPClient_Send($iSocket, $sData) _TCPClient_Broadcast($sData [, $iExceptSocket = 0 ]) _TCPClient_ListConnections() _TCPClient_BindAppToSocket($iSocket, $sCommand [, $sWorkingDir = @WorkingDir ]) _TCPClient_SendToBound($iSocket, $sData) _TCPClient_UnBindAppToSocket($iSocket) _TCPClient_OnReceive($sCallback) _TCPClient_OnDisconnect($sCallback) _TCPClient_DebugMode([ $bMOde = "toggle" ]) _TCPClient_AutoTrim([ $bMode = "toggle" ]) _TCPClient_SocketToConnID($iSocket) _TCPClient_ConnIDToSocket($iConn) _TCPClient_SocketToIP($iSocket)Help file and more examples included! Latest version: 1.0.0 Download: https://www.autoitscript.com/forum/files/file/377-tcpclient-udf/ Changelog 1.0.0 - First release - 03/12/2015If you can't open the help file, please uncompress it, go to properties and click Unlock. Fork me on Github: http://github.com/jesobreira/tcpclient-udf