Results 1 to 4 of 4

Thread: [RESOLVED] Winsock: Getting IP of the client attempting to connect

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    47

    Resolved [RESOLVED] Winsock: Getting IP of the client attempting to connect

    Sorry if this has been asked before but i can't seem to find it on here

    I was just wondering whether it was possible to detect the ip of the client attempting to connect to you before you accept the connection, i'm looking for a way of implementing an ip blocker

    The only parameter i get when a remote client attempts to connect is the requestID. Is there a Winsock API function that can use this to get the ip of the remote client?

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Winsock: Getting IP of the client attempting to connect

    Something like this:
    Code:
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
        Dim IsBlocked As Boolean
        
        ' test to see if remote user is blocked
        
        IsBlocked = Winsock1.RemoteHostIP = "23.34.56.77"
        IsBlocked = Winsock1.RemoteHostIP = "127.0.0.1"
        
        If Not IsBlocked Then
            ' Accept the connection
            Winsock1.Accept requestID
        End If
    End Sub
    Please not that I did not write code to create a new socket and connect to that one. If you don't know how to do that, I can write code for that too.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    47

    Re: Winsock: Getting IP of the client attempting to connect

    Oh right

    So your saying that the RemoteHostIP property contains the address of the remote host before you accept the connection

    If that's the case then that's what i was looking for

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Winsock: Getting IP of the client attempting to connect

    I always thought it didn't contain the RemoteHostIP until it was connected.

    But I tested it and it works. Now to re-write my IP ban code.

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