Shoutbox

Block IP In VB - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Block IP In VB (/showthread.php?tid=30867)

Block IP In VB by DJeX on 09-02-2004 at 03:49 AM

Is there any way with a Winsock to block an IP from connecting to your computer? I can't seem to figure out how to do it. Any one know?


RE: Block IP In VB by Mike on 09-02-2004 at 06:08 AM

Well yes:
Put this in your ConnectionRequest  event:

code:
If Winsock.RemoteIP <> Winsock.LocalIP Then 'This will allow you only you to connect
Winsock.Close 'Close the connection
Winsock.Listen 'Start waiting for connections again.
Else 'Else
Winsock.Close
Winsock.Accept RequestID


Hope it helps :)
RE: Block IP In VB by DJeX on 09-02-2004 at 07:42 AM

So how would I get IP's from a listbox and block them?

Say if I had a listbox with IP's in them. How would I use that code above to block all the IP's in the listbox from connecting to my computer?


RE: Block IP In VB by Mike on 09-02-2004 at 11:20 AM

Try this:
On ConnectionRequest event:

code:

Dim i As Integer
For i = 0 to List1.Listcount -1 'loop in each listbox's items
If List1.List(i) = Winsock1.RemoteIP Then
Winsock1.Close
Winsock1.Listen
Exit Sub
End if
Next i
Winsock1.Close
Winsock1.Accept requestID

I believe that this should work.
Of course you need to change list1 and winsock1 to the right names :)
RE: Block IP In VB by DJeX on 09-02-2004 at 06:07 PM

Will this for block websites too?

Just to try it I got the IP of www.google.ca

The IP ( 66.102.7.104 )

But it dident work, when I opened IE it still loaded google.ca.

Do I need to stick that code in a timer to keep it updateing?


RE: Block IP In VB by Millenium_edition on 09-02-2004 at 06:11 PM

you can block your computer from connecting to an ip, using the HOSTS file.

but to block incoming IP's you'll need some leet c++ dll or some uber c++ code.


RE: Block IP In VB by DJeX on 09-02-2004 at 06:50 PM

quote:
Originaly Posted By: Millenium_edition
but to block incoming IP's you'll need some leet c++ dll or some uber c++ code


Umm I don't think so. Theres a way in VB I know that i've seen it before. I just can't figure out how to do it.
RE: Block IP In VB by Millenium_edition on 09-03-2004 at 02:50 PM

The vb way involves netstatting and closing connections, at least that's what I think because my guess is that a winsock hook or something like that is way too advanced for VB... I don't know, so don't take this as the only possibility...

Search pscode.com for VB firewalls, you'll understand ;)


RE: Block IP In VB by DJeX on 09-03-2004 at 06:14 PM

I understand, so I'll just make a netstat and when the IP appers close the connection.