E1M1 Posted August 1, 2012 Share Posted August 1, 2012 I am having trouble with converting autoit function to c++. Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP This is what I've managed to do so far. struct mystruct{ short a; unsigned short b; unsigned int c; char d[8]; }; int struct_size = sizeof(mystruct); getpeername(s, &mystruct, &struct_size); Error I get: type name is not allowed. edited Link to comment Share on other sites More sharing options...
jvanegmond Posted August 1, 2012 Share Posted August 1, 2012 It sounds lame, but Google is your friend: http://www.wiredrevolution.com/c/find-ip-address-from-remote-end-of-a-tcp-socketYou think you're the first to ever need this in C++? : ) github.com/jvanegmond Link to comment Share on other sites More sharing options...
E1M1 Posted August 1, 2012 Author Share Posted August 1, 2012 Thanks edited 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