|
-
Mar 11th, 2004, 05:16 PM
#1
Thread Starter
Frenzied Member
UdpClient.Receive troubles
Just playing with udp, was going to make two console apps, one to send a message the other to receive.
The example found under "UdpClient.Receive Method", just copied and pasted into an empty class, always gives me a SocketException: An invalid argument was supplied.
Can someone tell me what I'm missing?
Thanks,
Mike
-
Mar 11th, 2004, 05:49 PM
#2
Hyperactive Member
That example is a bad example. When you declare the UDPClient you need to bind it to the local end point.
Change your
Code:
Dim receivingUdpClient As New UdpClient
to something like this...
Code:
Dim receivingUdpClient As New UdpClient(New IPEndPoint(IPAddress.Parse("127.0.0.1"), 0))
HTH
-
Mar 11th, 2004, 05:57 PM
#3
Hyperactive Member
One more thing, the receive method is blocking so you might want to include that in a thread.
-
Mar 11th, 2004, 06:13 PM
#4
Thread Starter
Frenzied Member
Thanks, MagellanTX, that did the trick. I've seen other bad examples from MSDN (specifically with Sockets), but I've been able to figure it out myself. Much appreciated.
FWIW, right now I don't care about the blocking business as it's just a test program. Once I figure out what I want, I'll either put it in a thread, or see if there's an asynchronous method available.
Thanks again,
Mike
-
Oct 19th, 2004, 09:31 AM
#5
Hyperactive Member
MagellanTX: Thanks for this post!
Mike Hildner: Just out of curiosity, how did you finally solve the problem? Asyncronous or threaded?
Thanks,
Eric
--------------------------------------------------------------------------------------------------------------------
VB.net/C# ... Visual Studio 2019
"None of us are as smart as all of us."
-
Oct 19th, 2004, 09:47 AM
#6
Thread Starter
Frenzied Member
I never took it very far, so never bothered with programming anything asynchronous. I've worked with asynchronous TCP sockets, though.
I was thinking of using UDP for notification when a 911 call came in in a dispatch center. That way, everyone who is subscribing can get a message. But now I'm thinking of using message queues or something, not really sure of the best way. Haven't gotten to that part of the project yet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|