PDA

Click to See Complete Forum and Search --> : How do I find out the IP of clients logging on to the server?


vbDan
Nov 9th, 2000, 01:33 PM
Hi,

I am trying to write a server program and I was wondering
if anyone knows how I can find out what the IP address of
the client logging on to the server is?

I am using winsock API calls! Not the winsock control.

Thanks!

Nov 13th, 2000, 02:34 AM
Try this:

request.servervariables("remote_addr")

Good Luck!

da_silvy
Nov 13th, 2000, 03:26 AM
ummm... doesn't that only work in asp?

vbDan
Nov 13th, 2000, 03:26 PM
Thanks for your reply, it seems that this function
was the one I was looking for:


ToDo = getpeername(Csock, sADDR, Len(sADDR))
ToDo = sADDR.sin_addr
mRemoteIP = lngIPtoStrIP(ToDo)

Public Function lngIPtoStrIP(ByVal longip As Long) As String

Dim dotted As String
Dim i As Long
Dim tval As Long

If longip < 0 Then
tval = 255
longip = longip + 1
End If

For i = 1 To 3
dotted = dotted + CStr((longip Mod 256) + tval) + "."
longip = Fix(longip \ 256)
Next

dotted = dotted + CStr(longip + tval)
lngIPtoStrIP = dotted

End Function