System.Net.Sockets and Console applications (VB.NET)

Joined
Jun 12, 2003
Messages
8
Ok...heres what Im trying to do...

Im trying to write a SOCKS4-type proxy with a console interface to display status information. (e.g. I would type connections at the prompt and get a list of connected clients). Ive never written a network application before, but the logic seems simple enough. I found some sample code that listens for a TCP connection. The first packet I get from the client is to negotiate a connection. I get the target IP address and port number from the client.

I dont know what to do next. I presume I need to open a connection with the server. I tried this (I used reverse DNS to get the hostname from the IP address, which is probably bad because some reverse DNS lookups will probably fail):

this always times out
target = New System.Net.Sockets.TcpClient(EndHost, EndPort)


I searched google and planet source code supposedly has a sample proxy server in VB.NET, but I cant get to the site.
 
Why doesnt this work?

IPSocket = New Socket(Net.Sockets.AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim IPHost As IPHostEntry = Dns.GetHostByAddress("192.168.0.1")
Dim sEndPoint As New IPEndPoint(IPHost.AddressList(0).Address, EndPort)
IPSocket.Connect(sEndPoint)


Dns.GetHostByAddress crashes...
 
When you say Dns.GetHostByAddress crashes - what exception do you get?

Also if you drop to a command prompt and type
ping -a 192.168.0.1
what results do you get?
 
Back
Top