By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,220 Members | 1,682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,220 IT Pros & Developers. It's quick & easy.

Non-Blocking UDP in VB.NET for beginners?

P: n/a
I apologise in advance for this question has been answered at least in this

Unfortunately I'm pretty new at all this and still can't get the jist.

Basically I've implemented a UDPClient.Send and Receive, run the program and
realised what was ment by 'blocking' when i read the MSDN article. My
program hangs, waiting to receive something.

As the title says, I'm looking for a way to achieve this without blocking,
probably as answered in the thread I've linked, but in an example format, or
at least easier than even lamens terms?

I know I'm being a pain, thus the apologies.

Here is an example of the blocking udpclient procedure I'm using at the
moment: (oUDPClient is currently declared globally while I tried to figure
things out...)
Public Function HandleIncoming() As Boolean

Dim SendersIP As String
Dim ReceivedEx As String

Dim receiveBytes As [Byte]() =
Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
SendersIP = RemoteIpEndPoint.Address.ToString()
ReceivedEx = returnData.ToString()
'Do stuff with ReceivedEx...
HandleIncoming = True

Catch ex As Exception
HandleIncoming = False
Exit Sub
End Try

End Function
To add to the above, I'm using Visual Studio 2005 Standard Edition. I've
created a VB project and this networking stuff which I have no experience in,
is just a small, but unfortunately crucial part of it.

What I need the above procedure to do is trigger when an incoming
transmission is detected. The procedure can then 'select case' and react
depending on what it has received. All of which I'd like to do without the
application hanging/being blocked - so the user can go on using other
features whilst the UDPClient listens in the background.

I don't mind doing this with some sort of timer checking if there has been
something received, if there is no event that can be triggered available.
I'd prefer it if it didn't involve having to download someone's .DLL and
referencing that, but if thats the only way to do so then c'est la vie.

I've already had a look at two such methods, one provided by 'UnoLibs' and
another by the name of 'TinyServer'. Both of which do not appear to have
been written in Visual Studion 2005 and refer to lots of old/obsolete
namespaces which I've failed to update to be compliant/usable/error free, in
my VS05 SE.

Thanks in advance for any help you guys can provide.
Please respond to my posts via the newsgroup as the e-mail provided is not
Jul 24 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.