What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Block IP In VB

1 votes - 5 average   Block IP In VB
Author: Message:
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. Roll Eyes  Block IP In VB
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?
[Image: top.gif]
09-02-2004 03:49 AM
Profile PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
RE: Block IP In VB
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 :)

This post was edited on 09-02-2004 at 06:09 AM by Mike.
YouTube closed-captions ripper (also allows you to download videos!)
09-02-2004 06:08 AM
Profile E-Mail PM Web Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Block IP In VB
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?
[Image: top.gif]
09-02-2004 07:42 AM
Profile PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
RE: Block IP In VB
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 :)

This post was edited on 09-02-2004 at 11:21 AM by Mike.
YouTube closed-captions ripper (also allows you to download videos!)
09-02-2004 11:20 AM
Profile E-Mail PM Web Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Block IP In VB
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?
[Image: top.gif]
09-02-2004 06:07 PM
Profile PM Web Find Quote Report
Millenium_edition
Veteran Member
*****

Avatar

Posts: 1787
Reputation: 57
Joined: Apr 2003
RE: Block IP In VB
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.
09-02-2004 06:11 PM
Profile E-Mail PM Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Block IP In VB
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.
[Image: top.gif]
09-02-2004 06:50 PM
Profile PM Web Find Quote Report
Millenium_edition
Veteran Member
*****

Avatar

Posts: 1787
Reputation: 57
Joined: Apr 2003
RE: Block IP In VB
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 ;)
09-03-2004 02:50 PM
Profile E-Mail PM Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Block IP In VB
I understand, so I'll just make a netstat and when the IP appers close the connection.
[Image: top.gif]
09-03-2004 06:14 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On