VB Net Socket Error?



I wrote a few lines of code to send a UDP packet to a remote machine. What
worries me is the program code says it sends the data regardless of the
remote IP or port. If the IP is ok , a sniffer verifies the packet was sent.
However, if I give the sendto statement a bogus IP or port (that is not open
on the remote machine), the code executes with no errors. I know UDP is
connection-less, but the framework should balk at the bad or port (or at
least it does in C or VB6). Any ideas how to get an error return? I used to
get a destination or port unreachable error in VB6, when I did a sendto with
a bogus IP or closed port. Heres the code:
Lets say my network is
Dim txString() As Byte = Encoding.ASCII.GetBytes("test")
txSocket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
Dim txEP As New IPEndPoint(IPAddress.Parse(""), 2967)
Dim r = txSocket.SendTo(txString, txEP) 'returns 5 bytes data sent to 172
network (ip not exist)
Catch ex As Exception
End Try


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

.Net Sockets 2
vb .net opening a socket into secure unix 2
Error handling in vb. net 3
VB to .Net 6
.NET Sockets Help 1
.net socket question 0
How in VB .NET to correct errors? 1
VB SCript in .NET? 9