Discussion in 'Mac Programming' started by KylieM, Dec 25, 2014.

  1. KylieM macrumors newbie

    Dec 20, 2014
    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?


  2. chown33 macrumors 604

    Aug 9, 2009
    descending into the Maelström
    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:

    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:

    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:

    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:

    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.

Share This Page