Re: UDP support for NSStream
Re: UDP support for NSStream
- Subject: Re: UDP support for NSStream
- From: Jens Alfke <email@hidden>
- Date: Sun, 3 Aug 2008 11:42:02 -0700
On 3 Aug '08, at 10:45 AM, Liwei wrote:
Hmm, I can't seem to find information about how I may listen to and
make a broadcast over UDP. It seems that it needs to be connected in
some way first. How do I configure a connectionless UDP socket?
I've done this, but it was years ago and I don't have access to the
source code anymore. :-(
IIRC, you create the CFSocket, using the right protocol constants for
UDP, but don't connect it to a destination address. Then every time
you want to send a packet, you call CFSocketSendData, with the
'address' parameter set to the address you want to send that packet
to. You'll need to open another CFSocket for listening for incoming
packets.
Do you mean "broadcast" literally? Instead of using UDP broadcast,
which is deprecated, you should use multicast with an address in the
link-local multicast range. (IIRC, the reason is that a UDP broadcast
will be received by every single machine on the subnet, while a
multicast can be ignored by machines that aren't listening on that
particular multicast address.) Modern services like Bonjour use
multicast.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden