Need help on UDPclient.receive

G

Guest

Hi All,

I've allready posted this on the C# group (oops).

I'm trying to get a UDPclient to receive. I use the sample code provided in
HELP but to nbo avail. When the receive method is executed, it throws an
exception, claiming an invalid argument was used. The WinAPI description on
MSDN says:

Invalid argument.
Some invalid argument was supplied (for example, specifying an invalid level
to the setsockopt function). In some instances, it also refers to the current
state of the socket—for instance, calling accept on a socket that is not
listening.

which doesn't get me any further. I don't get it.

Please HELP,

Peter

Sample Code:

'Creates a UdpClient for reading incoming data.
Dim receivingUdpClient As New UdpClient()

'Creates an IPEndPoint to record the IP address and port number of the
sender.
' The IPEndPoint will allow you to read datagrams sent from any source.
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Try

' Blocks until a message returns on this socket from a remote host.
Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)

Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)

Console.WriteLine(("This is the message you received " +
returnData.ToString()))
Console.WriteLine(("This message was sent from " +
RemoteIpEndPoint.Address.ToString() + " on their port number " +
RemoteIpEndPoint.Port.ToString()))
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub 'MyUdpClientCommunicator
 
G

Guest

I found a workaround: use sockets and screw the UDPclient

just great....

Peter (Plem)
 

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

Top