sentry07 Posted March 15, 2013 Share Posted March 15, 2013 Still working on my terminal program, and a thought came to me. I've created a TCP server and something connects to it, how do I find out the IP address of what has connected to it? There are no functions that I can find that give me any information about the connected socket. I searched the forum but didn't find anything. Link to comment Share on other sites More sharing options...
Exit Posted March 15, 2013 Share Posted March 15, 2013 Use NETSTAT command. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
dragan Posted March 16, 2013 Share Posted March 16, 2013 (edited) Func _TCP_Server_ClientIP($hSocket) Local $pSocketAddress, $aReturn $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]") $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress)) If @error Or $aReturn[0] <> 0 Then Return $hSocket $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3)) If @error Then Return $hSocket $pSocketAddress = 0 Return $aReturn[0] EndFunc ;==>_TCP_Server_ClientIP Edited March 16, 2013 by dragan sentry07 1 Link to comment Share on other sites More sharing options...
sentry07 Posted March 16, 2013 Author Share Posted March 16, 2013 Perfect. Works great! 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