T
Tommy Long
I apologise in advance for this question has been answered at least in this
thread:
http://forums.msdn.microsoft.com/en-US/netfxnetcom/thread/9b7d3a8f-b964-45a7-ba7d-1a567f406757
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
Try
Dim receiveBytes As [Byte]() =
oUDPClient.BeginReceive(RemoteIpEndPoint)
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.
thread:
http://forums.msdn.microsoft.com/en-US/netfxnetcom/thread/9b7d3a8f-b964-45a7-ba7d-1a567f406757
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
Try
Dim receiveBytes As [Byte]() =
oUDPClient.BeginReceive(RemoteIpEndPoint)
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.