This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

More on passing file descriptors


Hello,
	I've talked for a while and sent a couple of messages regarding
file descriptor passing through UNIX sockets.  I've done a little more
research and determined the following:

Refer to http://cygwin.com/ml/cygwin/2002-06/msg00227.html for some
details.

Unfortunately for this to work properly the message boundaries need to
be preserved.  Why? Because if I send two messages with two file
descriptors.  And you read all the data in one turn, how are you going to
return two file descriptors?

There are three solutions to preserving the message boundaries.
#1 Tag all data with lengths when using Unix sockets.  This comes at a
very little overhead.  Unfortunately if you send lots of 1 byte packets
and want to read them all at onec you won't be able to.

#2 Before sending a message with a file descriptor send a MSG_OOB msg.
This, at least in Win2k, makes the system preserve the message boundaries.
However MSDN says never to use OOB messages.

#3 Make the cygserver manage how much data is read.  i.e.  Before sending
4 bytes, tell the cygserver that you  you are sending 4 bytes,  then the
receives asks the cygserver, how much it can read.  (This seems hideous,
but probably more similar to what UNIX sockets do in UNIX.

Comments?
David


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]