slightly modified MS example
Imports System.Web
Imports System.net
Imports System.net.Sockets
Imports System.Text
Module Module1
Sub Main()
'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, 514)
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
Console.ReadLine()
End Sub
Scott H wrote:
OK, what am i doing wrong here.....
-------------------------------
Dim ServerIPEP As New System.Net.IPEndPoint(System.Net.IPAddress.Any,
514)
Dim UDPc As New System.net.Sockets.UdpClient
Dim receiveBytes As Byte() = UDPc.Receive(ServerIPEP) 'fails here
Dim returnData As String =
System.Text.Encoding.ASCII.GetString(receiveBytes)
MsgBox(returnData)
--------------------------------
All I'm trying to do is listen for any UDP packets on port 514 and I
get "An invalid argument was supplied" on the .Receive method
Scott H
Regards - OHM#
On**********@BTInternet.com