To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Mar 14th, 2007, 12:57 AM   #1
corydg
Junior Member
 
Join Date: Nov 05
Location: Bentonville, AR
Posts: 22
corydg is an unknown quantity at this point (<10)
some udp help

Hi,

I have a piece of software running on a linux box that is transmitting information every few minutes over UDP to a destination port of 3052. After looking at a packet sniffer, the data is making it to the computer that I am having problems with.

I need to create a program that will listen on port 3052 and receive that data. I have tried for several hours to find source code to listen only, but i'm having little luck with that. I am using VB .net 2005.

thanks,

cory
corydg is offline   Reply With Quote
Old Mar 14th, 2007, 01:17 AM   #2
jmcilhinney
.NUT
 
jmcilhinney's Avatar
 
Join Date: May 05
Location: Sydney, Australia
Posts: 54,913
jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)
Re: some udp help

The MSDN help topic for the UdpClient.BeginReceive method has a code example of basically what you want. It's in C# only, but here's a translation courtesy of Instant VB:
vb Code:
  1. Public Shared messageReceived As Boolean = False
  2. Public Shared Sub ReceiveCallback(ByVal ar As IAsyncResult)
  3.   Dim u As UdpClient = CType((CType(ar.AsyncState, UdpState)).u, UdpClient)
  4.   Dim e As IPEndPoint = CType((CType(ar.AsyncState, UdpState)).e, IPEndPoint)
  5.   Dim receiveBytes As Byte() = u.EndReceive(ar, e)
  6.   Dim receiveString As String = Encoding.ASCII.GetString(receiveBytes)
  7.   Console.WriteLine("Received: {0}", receiveString)
  8.   messageReceived = True
  9. End Sub
  10. Public Shared Sub ReceiveMessages()
  11.   ' Receive a message and write it to the console.
  12.   Dim e As IPEndPoint = New IPEndPoint(IPAddress.Any, listenPort)
  13.   Dim u As UdpClient = New UdpClient(e)
  14.   Dim s As UdpState = New UdpState()
  15.   s.e = e
  16.   s.u = u
  17.   Console.WriteLine("listening for messages")
  18.   u.BeginReceive(New AsyncCallback(AddressOf ReceiveCallback), s)
  19.   ' Do some work while we wait for a message. For this example,
  20.   ' we'll just sleep
  21.   Do While Not messageReceived
  22.     Thread.Sleep(100)
  23.   Loop
  24. End Sub
__________________

2007, 2008, 2009, 2010

Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB | C# (ForumAccount has translated some of my VB submissions to C#)
My Blog: Defining and Raising Custom Events | Manipulating GDI+ Drawings | Using Parameters in ADO.NET
jmcilhinney is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:37 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.