Hello everybody,

Please can You show me how i get the Clients IP with my Code ?

mov eax,lparam_
cmp ax,008h ;FD_ACCEPT
jne go_on
shr eax,16
xor ebx,ebx
invoke CheckSocketList
invoke accept ,,0,0
inc Counter
mov ,eax
invoke wvsprintfA,addr Count,addr Hex2Dec,addr Counter
invoke SetDlgItemTextA,Hwnd,IDD_USER,addr Count

im very new to Masm and dont understand the Post i found by using the Search Function.

Many Thanks
Posted on 2002-05-09 09:35:53 by cruzmann
Your problem is that you call accept without specifying a pointer to a sockaddr structure.

invoke accept ,,0,0

should be

invoke accept, listensock, addr client_addr, 0

where client_addr is a sockaddr_in struc. If you want to do it without relying on accept() then you can use getpeername(). The parameters are the same.
Posted on 2002-05-09 14:30:01 by iblis

after reading the post i try to get it working so i use
from my win32.inc the dword sin_addr

i call getpeername like this:
invoke getpeername, listensock, addr sin_addr, 0

but the result is allways empty.

cruzmann can you show me how do you get it working please ?

Posted on 2002-06-30 03:32:56 by xanthos
Have you defiend your address structure somwwhere
client_addr sockaddr_in <?>
invoke accept, listensock, addr client_addr, 0
;now convert the IP to doted format
invoke inet_ntoa, client_addr.sin_addr
Posted on 2002-06-30 05:14:15 by Kudos
Hello Kudos,

thanks for your quick help.

yes i use client_addr sockaddr_in <?>

also i wrote:
invoke accept ,,addr client_addr,0
invoke getpeername,,addr client_addr,0
invoke inet_ntoa,client_addr.sin_addr
lea ebx, ipbuff
invoke lstrcpy,addr remip,eax

but "remip" is allways

i connect to the portwatcher when im online and use ip
possible i have to wait for a connection from some other user ?

Posted on 2002-06-30 08:40:33 by xanthos
ups no use of getpeername :-)
now it works fine , thanks for the help.

mov eax,lparam_ ;FD_ACCEPT?
cmp ax,008h
jne go_on
shr eax,16
xor ebx,ebx
call CheckSocketList
call accept ,,offset client_addr,offset len ;Accept the connection
mov , eax ;get remote ip
mov eax, dword ptr
mov , eax
mov eax, offset LoggedUsers
sub eax, 16
mov ecx, 0
call inet_ntoa,
mov , eax
call lstrcpy,offset remip, ;copy remote ip to buffer
inc Connections
mov ,eax
call wvsprintfA,offset Connectionsstr,offset Hex2Dec,offset Connections
call SetDlgItemTextA,hwnd_,IDD_TOTUSER,offset Connectionsstr ; count connection
call lstrcpy,offset LOGTXT,offset INTRUDIN ; write to log
Posted on 2002-06-30 11:20:33 by xanthos