473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Listening for UDP


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
Nov 20 '05 #1
3 5363
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
Nov 20 '05 #2

Thanks.....but I get the same error:
"An Invalid argument was supplied" when it runs the .Receive method
Tried different port numbers too, just in case it was trying to listen
on a port/address that was already listening.

Something wrong with my .NET or windows?

Scott
On Tue, 16 Dec 2003 08:31:41 -0000, "One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote:
slightly modified MS example <SNIP>

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


Nov 20 '05 #3

Just in case anyone gets this problem, I just found out how to fix it.

Instead of:

Dim receivingUdpClient As New UdpClient
(as stated in many "help" files, newsgroups and message boards)

I put:

Dim receivingUdpClient As New UdpClient(514)

Even though the next line is:

Dim RemoteIpEndPoint As New
System.Net.IPEndPoint(System.Net.IPAddress.Any, 514)

Does that mean its listening on port 514 for packets on remote port
514? (both server and client on port 514?)

Anyway, it worked, received packets from a SYSLOG server just fine!

Scott H
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Laszlo Csabi | last post by:
Hi guys, What I would like to achieve is create a client-server messenger application. The problem I run into is : I have created a listener socket on the client and connect to the remote...
1
by: Akif | last post by:
Hi. I'm a SQL Server novice, so apologies if any of this sounds simple. I am running Windows XP SP2, and have just installed SQLServer 2000. I need another application to connect to SQLServer,...
5
by: Adam | last post by:
Hi, How do i listen for windows messages in c# on compact.net? I have a window containing an instantiation of the HTML viewer control, which is a child of the main form. As the compact...
0
by: Dave L | last post by:
I just upgraded from VS .NET 2002 to 2003. Everything built okay, but strange bugs started appearing. Apparently there is a bug in the managed C++ compiler in regards to handling of static...
2
by: Lenard Gunda | last post by:
Hi, I have the following problem when I am working with sockets in C#. I do not remember running into the same problem some while ago, when working with sockets from C++ (using native code, not...
6
by: kai | last post by:
Hi, I was tring to run an example (HelloWorld.aspx) from MSPrss book, I get this message: "ASP.NET Development Server faild to start listening port 1034. Error message: An attempt was made...
6
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine,...
0
by: Daniel Walton | last post by:
I have been working on a problem for a full week now. If someone could please help me it would be great. Even a clue would be great at this point. What I am seeing is quite a mystery. I have...
10
by: ThunderMusic | last post by:
Hi, I'm currently working with sockets. I accept connections using m_mySocket.Listen(BackLogCount); But when I want to stop listening, I shutdown all my clients and call m_mySocket.Close(), but it...
5
by: rome ez | last post by:
I am trying to write a vb.net socket application which listens for clients on two ports simultaneously. Is it possible to do so and how can this be done. Please help.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.