Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

KylieM

macrumors newbie
Original poster
Dec 20, 2014
3
0
Hi everyone

I am trying to use NSSocketPort in order to broadcast message to the LAN network and also receive message broadcasted to UDP.
Unfortunately I can't find a proper guide to perform this task.
Can anyone please tell me what is the procedure to do this or point me to a document explaining this subject?

Thanks,

KylieM
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
Please explain how you came to the conclusion that this class would do what you want.

Did you follow a tutorial? Read a book? Some other reference? Download sample code? Use a library? If any of those are true, which ones? For those that are true, exactly which one (post its URL)?

When I google NSSocketPort, one of the top hits is this:
http://www.cocoabuilder.com/archive...unication-with-nsfilehandle-nssocketport.html

It's from 2008, but does discuss using the class. Among other things, such as pointing to examples of using it as a TCP listener (note: not UDP), is this observation:
NSSocketPort is part of the Distributed Objects API - despite the
name, it's not a general-purpose socket class. ...​
This is consistent with the online class reference doc:
https://developer.apple.com/library...erence/Foundation/Classes/NSSocketPort_Class/

On the left, notice that the Related Documentation is only for Distributed Objects, not for generalized networked communications.

In short, I don't think NSSocketPort will do what you want. If you have reason to think otherwise, please explain.


For OS X's TCP/IP networking as a general subject, you could start here:
https://developer.apple.com/library...cs/Articles/UsingSocketsandSocketStreams.html

Be sure to read the Related Documentation linked at the left.

Here's how I got to that article:
https://developer.apple.com/search/?q=networking topics&platform=OS X

That is, I went to Apple's developer search page, I searched for the words networking topics, limited it to the OS X platform, and the top result had the sockets and streams article.

Here's UDP sample code:
https://developer.apple.com/library/mac/samplecode/UDPEcho/Introduction/Intro.html

I got there by searching for UDP on Apple's developer search page.

You may also find that multicast, and Bonjour specifically, is more suitable than UDP broadcast.

There are plenty of resources, but you need to ask a specific question, and specify which programming language you're working in.


In another thread you said you were an experienced Windows developer, but gave no details. What languages does that include? What kinds of programs have you written: apps? device drivers? command-line tools?

Have you done any network programming on the Windows side yet? Using what languages (and classes or libraries)?

In particular, if you've already got a Windows program that broadcasts messages and receives UDP (i.e. does what you asked for), what language and libraries did you use? Be specific. If there's an equivalent on OS X, then we need to know exactly what you used on Windows in order to figure out what the OS X equivalent is.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.