Results 1 to 4 of 4

Thread: How do I find out the IP of clients logging on to the server?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    34
    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!

  2. #2
    Guest

    Cool

    Try this:

    request.servervariables("remote_addr")

    Good Luck!

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    ummm... doesn't that only work in asp?

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    34
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width