Setting up a socket

Effectively what I need to do is to set up Unix sockets (server and client) for a serial port (as provided by a USB-to-Serial adapter). This socket would then be used to communitate with a Windows XP app running under a Parallels VM. True the hardware resource could be bound directly to the VM, but this doesn't work very well (to slow). It is my hope that, by keeping the hardware resource on the Mac side of the equation and having OSX take care of buffering and flow control, that it will eliminate the data loss I am seeing now. No problem setting up the sockets on the VM side, but I have no idea what needs to be done on the OSX side.

(Yes, I know that even the way I present this problem is probably flawed since I know very little about this whole area. Please be patient.)

 20" Intel iMac (2.0GB RAM, 500GB HD + 1.5TB external, 20" Cineama Display), Mac OS X (10.4.7), All tools, no talent!

Posted on Aug 31, 2006 9:39 AM

Reply
11 replies

Aug 31, 2006 3:35 PM in response to transco

well, I don't know if what you're trying to do will work. though it would be neat if it does.

To set up a unix socket, see the unix(4) manpage.

if you scratch out a program that accesses the network it should be to hard. It should also be possible to do this using perl.

perldoc -f socket
socket SOCKET,DOMAIN,TYPE,PROTOCOL
Opens a socket of the specified kind and attaches it to file-
handle SOCKET. DOMAIN, TYPE, and PROTOCOL are specified the
same as for the system call of the same name. You should "use
Socket" first to get the proper definitions imported. See the
examples in "Sockets: Client/Server Communication" in perlipc.

On systems that support a close-on-exec flag on files, the flag
will be set for the newly opened file descriptor, as determined
by the value of $^F. See "$^F" in perlvar.

Aug 31, 2006 5:31 PM in response to Nils C. Anderson

It's been a long time since I've done any programming (when I started, computers were made with vacuum tubes and we programmed them with patchcords). I went back and took a look at the Windows app that I need to share a socket with. The only option is to allow you to set the socket name (the example they give is '/tmp/serial') and you do this for both client and server sockets.

Anyway, can you recommend a free universal Perl interpreter and/or compiler? You make a references 'To set up a unix socket, see the unix(4) manpage'. Could you elaborate?

Might be a hopeless cause, but thanks for trying.

Aug 31, 2006 6:58 PM in response to transco

the manpage that I referred to can be found by running:

man 4 unix

at the unix prompt that you get after opening the Terminal.app. Or it can be found at:

http://developer.apple.com/documentation/Darwin/Reference/ManPages/man4/unix.4.h tml

For perl, open the Terminal.app which is in the Utilities Folder that located in the Applications Folder. OS X comes with perl, all that is needed is a good book on how to program perl. Every one has there preferences, I liked this one the best

http://www.amazon.com/gp/product/0130089656/104-3603176-6871111?v=glance&n=28315 5

O'Reilly has a number of good perl programming books as well.

http://www.oreilly.com/pub/topic/perl

Regards,

Andy

Aug 31, 2006 9:52 PM in response to Nils C. Anderson

So happens I have a couple Perl books in my library: 'Mastering Perl 5' and 'Cross-Platform Perl'. Time to start reading I guess. Do you by any chance know where I might find applicable source code I could study? Again, my basic task is to make the Mac serial ports available to the VM. There are provisions in the VM for setting up client and server sockets, and I guess they do the rest on their side for you. I just need to write a hopefully simple routine that makes the Mac's SIO ports available to an external process (the VM in this case).

Sep 1, 2006 7:25 AM in response to transco

If you are getting in over your head, may as well go head-first!

I think you can do what you want using Netcat. You can download the source and compile it yourself using Apple's Xcode development tools. Or, you can download a precompiled version from darwinports or fink.

Then, do something similar to the instructions here. Your serial device may be something like /dev/**.usbserial0. I have a hard time keeping serial port straight on *nix systems.

Good luck!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Setting up a socket

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.