Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 11 Jun 2002 10:27:39 -0400 (EDT) From: David E Euresti To: Subject: More on passing file descriptors Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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/