.net udpclient - listening issue

Joined
Feb 15, 2002
Messages
1,003
Hey everyone, I've got a pretty straightforward UDP client set up - but I'm getting some issues with the Windows firewall and event log messages because it seems like the UDP client is trying to listen on a port even though I haven't told it to.

I'm beginning to wonder if the udpclient class listens on a port regardless of whether or not you are actually using the recieve function. Was hoping someone might have some insight as to how I can stop it from listening.

Code:
dim udpClient As New UdpClient
dim message as Byte() = New Byte() {}
dim x As Integer
Try
   message = encoding.ASCII.GetBytes("text here")
   x = udpClient.Send(message, message.length, servername, port)
catch ex as Exception

Finally
udpclient.close()
ctype(udpClient, IDisposable).dispose()
End Try
 
For now I'll just post the MSDN documentation on UdpClient, since it seems the most relevant. You are calling Send() without calling Connect(), which should be some kind of an issue since you are using the default constructor.

202276
 
Well, I was previously using connect before I used send. But then I thought that perhaps the connect method was causing the client to open a port to listen on, so I took it out.

The client actually still sends UDP messages to the server, but if no ports are available on the computer to be opened the client will just do an outbound port scan of sorts, trying to open thousands of closed ports per second - causing the Windows security event log to get an entry for each port.
 
Back
Top