Question Block internet port

tukmolins

Member
Joined
Oct 21, 2011
Messages
12
Programming Experience
1-3
Hello everyone! Is there any way visual studio block Port 8080 to stop the internet? I want to make an administration system and I have a functionality that blocks the internet of a computer but everytime i look for a solution in the web it is either from another language or just a discussion about network protocols. Can someone help me? I had a background of tcp/ip protocols but i really can't figure it out and convert it to codes using visual studio. Thanks in advance :) ciao!
 
The easiest thing to do is open the TCP port you want to block in your application and then ignore anything that comes in. Stopping outbound data is more difficult unless you are willing to write a driver to intercept TCP traffic.
 
still no luck for me in doing this using vb. can you show me some codes to start off in blocking port 8080? thank you


i only got this from your idea to open a port. is this what you mean? thank you
[XCODE]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim listener As New TcpListener(8080)
Dim client As TcpClient


listener.Start()


While (True)
client = listener.AcceptTcpClient()


Dim bytesFrom(10024) As Byte
Dim dataFromClient As String


Dim networkStream As NetworkStream = client.GetStream()
networkStream.Read(bytesFrom, 0, CInt(client.ReceiveBufferSize))
dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom)
End While


client.Close()
listener.Stop()
End Sub
[/XCODE]
 
Last edited:
You will probably also want to set client.ExclusiveAddressUse to True to prevent any other connections from being made. See ExclusiveAddressUse Property for more details on its use.

You should also add some kind of error handler around your While loop or an exit mechanism to prevent leaks just in case the user decides to kill the process.
 
Well firstly, this won't work unless you block port 80 (the default port for HTML) as well.
Secondly, it is my understanding that although the client connects to the server on port 80, the server actually responds to the client on an arbitrarily selected port number. This could render the proposal azuckerman is making somewhat infeasible. Unfortunately I don't know what I'd replace it with; VB.net doesn't generally work on a low enough level to interfere with networking protocols.
 
Well firstly, this won't work unless you block port 80 (the default port for HTML) as well.
Secondly, it is my understanding that although the client connects to the server on port 80, the server actually responds to the client on an arbitrarily selected port number. This could render the proposal azuckerman is making somewhat infeasible. Unfortunately I don't know what I'd replace it with; VB.net doesn't generally work on a low enough level to interfere with networking protocols.

This will work on any port that isn't already in use exclusively for in-bound traffic. By accepting the in-bound connection and request, but not responding to it, you effectively block the port.

As noted above, this won't work for out-bound traffic because another process could just open any available port for out-bound. To prevent out-bound traffic you would have to intercept the communications at a driver level.
 
Back
Top