-
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!
-
Try this:
request.servervariables("remote_addr")
Good Luck!
-
ummm... doesn't that only work in asp?
-
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