[Openmcl-devel] OSX and CCL sockets problems

Joshua Kordani jkordani at lsa2.com
Tue Dec 9 08:33:45 PST 2014


Greetings all,

Working on some code to fetch data from sony cameras on a network.  using wireshark I'm able to discover what the oem software does to discover devices on the network.  I've run into 3 issues in particular.  The below paste is the code concerning this activity.

http://paste.lisp.org/display/144639

The cameras listen on 2380 for a udp message with some contents, and then emit their data to the broadcast address to the same port.  I figured I'd do this in two parts, stand up a listen socket on the interface that the user expects cameras to be reachable from, and then emit the bytestring to get the cameras to elicit their data, then later scarf up whatever comes in on the listen port at some later point.  So I figured a user would call sony-start-listen, then find-sony whenever they wanted the cameras to emit.  and then for my testing purposes I just immediately poll the listen socket for data in the find-sony call, but theoretically I should be able to do this at any later point and get the data.

I have run into 3 problems.

Firstly, it seems that on OSX, if you attempt to call sent-to on a socket already "connected", which would be done if you include the :remote-host and :remote-port parameters to make-socket, osx barfs with a socket error 56.  posts on the internet suggest that this behavior differs from linux where this restriction is ignored and the "right thing" seems to be done instead, which is to send your data after all.
See https://github.com/zerovm/zerocloud/issues/86
This behavior differs from what is described in the ccl documentation for these calls.  The workaround seems to be to instead use find-sony like http://paste.lisp.org/display/144639#1  where the socket is stood up without the remote parameters and instead every call to this socket explicitly use the remote parameters.

Secondly, it seems that the :reuse-address t parameter is not honored by the os, when I use start-listen and later inside find-sony when I attempt to stand up the temporary socket object, osx barfs with socket error 48, address already in use during bind.

Thirdly, if I use annotation 2  http://paste.lisp.org/display/144639#2 for find-sony, and do NOT use the start-listen and stop-listen call, where I instead just open the temporary socket, emit the data and then listen for a response, in spite of watching the packet come through on wireshark, and in spite of netstat -an | grep 2380 showing that I have a process listening on the correct port on the correct interface, the call to receive-from just blocks.  The camera responses are a couple hundred bytes, they differ based on strings for names and such, and my current camera I'm testing with emits a packet with 400 bytes in it, so if the blocking is caused by waiting till I receive 300 bytes, then that isn't my problem.  It seems like the socket I'm trying to receive-from is not the one thats actually received any data.

I'm on osx 10.7 using 1.11-dev-r16325M-trunk

Can anyone help me sort through what's going on?

Thanks



-- 
Joshua Kordani
LSA Autonomy



More information about the Openmcl-devel mailing list