David,
Good idea...
The code below is a sample from the VS help... very straight forward. No
default host is set with the connect method so it should receive from any
host... it doesn't
It bangs out saying:
---------
System.Net.Sock ets.SocketExcep tion: Invalid Argument
at System.Net.Sock ets.Socket.Rece iveFrom(Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
at System.Net.Sock ets.Socket.Rece iveFrom(Byte[] buffer, Int32 size,
SocketFlags socketFlags, EndPoint& remoteEP)
at System.Net.Sock ets.UdpClient.R eceive(IPEndPoi nt& remoteEP)
---------
********
Private Function MicrosoftSample () As Integer
'Creates a UdpClient for reading incoming data.
Dim receivingUdpCli ent 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 RemoteIpEndPoin t As New IPEndPoint(IPAd dress.Any, 0)
Try
' Blocks until a message returns on this socket from a remote
host.
Dim receiveBytes As [Byte]() =
receivingUdpCli ent.Receive(Rem oteIpEndPoint)
Dim returnData As String = Encoding.ASCII. GetString(recei veBytes)
Console.WriteLi ne(("This is the message you received " +
returnData.ToSt ring()))
Console.WriteLi ne(("This message was sent from " +
RemoteIpEndPoin t.Address.ToStr ing() + " on their port number " +
RemoteIpEndPoin t.Port.ToString ()))
Catch e As Exception
Console.WriteLi ne(e.ToString() )
End Try
End Function
*******
If I create an instance of an IPEndpoint and set it to the remotehost, this
occurs just the same. If I first use the connect method to set the default
host, the code hangs in the receive method as if there is nothing to receive.
(I KNOW that is not true)
Peter
"da*********@eu rope.com" wrote:
Plem,
Please include your source...