• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UDP endpoints
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UDP endpoints


  • Subject: Re: UDP endpoints
  • From: Quinn <email@hidden>
  • Date: Wed, 10 Jul 2002 09:41:32 +0100

At 14:11 -0400 9/7/02, mike yurick wrote:
I have a few problems. I'm writing a program in a very high-level,
interpreted language (MATLAB for Mac to be precise) and I need
communications facilities which this language doesn't provide. It DOES let
me call C functions at runtime though, so I'm trying to use OT to establish
communications with a UNIX machine. I'm using UDP packets to send commands
from the UNIX machine to the Mac, and the program receives this info via one
of these C function calls. Essentially, it just loops, checking for a new
command at the beginning of each iteration and then performs the appropriate
operations. The communication that has to take pIace is really simple. I
was just going to write a C function that checks a UDP endpoint with OTLook
to see if there's any info there waiting and then return the data if its
there or some other value if it isnt, but the documentation I've read
recommends that I use a notifier function. Why?

Using a notifier allows you to avoid polling for data. However, given that your higher-level application structure requires polling, there's no point in reducing polling at the lowest level only to reintroduce it at the higher levels. With your current design it seems that polling for data is perfectly reasonable. You don't even need to call OT look. Just set the endpoints in synchronous non-blocking mode and then call OTRcvUData. You'll either get data or a kOTNoDataErr.

Also, if I initialize OT
in one isolated C function call at runtime, will I be able to make
subsequent OT calls in other isolated C function calls as long as I haven't
shut it down anywhere?

This depends on how your C functions are loaded by MATLAB. Typically in this sort of plug-in environment you have a CFM shared library and you initialise OT when the library is loaded and terminate OT when the library is unloaded. If that's the design, then OT assets (such as endpoints) will stay around for as long as the library is around, assuming you initialise OT correctly. See TN 1173 for info on how to init OT in a library.

<http://developer.apple.com/technotes/tn/tn1173.html>

The real question is whether MATLAB loads the library once at launch and unloads it at quit, or whether it loads and unloads the library between each function call. If it's the former, everything will be good. If it's the latter, you'll have to jump through some hoops. I can explain those hoops if necessary.

And do endpoints remain bound to an ip/port across
calls like this?

If the endpoints stay around then they'll remain bound.

Also, due to the way this language operates, I don't think
it will be possible to pass around endpoint references from one C function
to the main program and then back to another C function, so I was wondering
if there is any way to open a UDP endpoint on an ip/port and then check the
ip/port for info without the endpoint reference?

I think Michael Paluszek's idea of maintaining an array global variable indexed by an integer value is probably a great solution to this.

Or is there someway for me
to get the enpoint reference that is bound to an ip/port?

It is possible to do, but if you're already passing around an IP/port you can just as easily pass around an integer array index.

S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

References: 
 >UDP endpoints (From: mike yurick <email@hidden>)

  • Prev by Date: Re: OTIoctl Question
  • Next by Date: Debuging stack varialbe overwrite on MacOS9
  • Previous by thread: Re: UDP endpoints
  • Next by thread: send on unconnected socket = crash (TCP sockets on X)
  • Index(es):
    • Date
    • Thread