|
-
Jun 2nd, 2007, 11:57 AM
#1
Thread Starter
Member
[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?
-
Jun 2nd, 2007, 12:12 PM
#2
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.
-
Jun 2nd, 2007, 05:22 PM
#3
Thread Starter
Member
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
-
Jun 2nd, 2007, 06:29 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|