Re: writeData: Question
Re: writeData: Question
- Subject: Re: writeData: Question
- From: "Justin C. Walker" <email@hidden>
- Date: Wed, 21 May 2003 22:25:36 -0700
On Wednesday, May 21, 2003, at 09:36 PM, Josh Morris wrote:
I am trying to write a program that will need to write to multiple
sockets simultaneously. In the GNUStep docs there is a
writeInBackgroundAndNotify: method, whereas Cocoa has a similar method
only for reading sockets.
Since writeData: is synchronous it will not return until the data
passed to it is sent over the socket, correct? What recourse do I have
with NSFileHandle? Thanks in advance.
I can't speak directly to the NS APIs, but: writes in Unix-style
systems are typically asynchronous from the perspective of the device
receiving the data (e.g., for a disk file, the data in a write command
is copied to a kernel buffer, and control returns to the user program;
it's up to the kernel to attend to getting the data to the disk). For
sockets, this depends to some extents on the underlying protocol, but
generally, the data is read from user mode and control is returned to
the writing program.
You can control this to some extent by conditioning the socket (file
descriptor) with the open(2) and fcntl(2) system calls (see the man
pages; look for O_ASYNC and O_NONBLOCK/FNONBLOCK).
The answer really depends on the protocols involved (there's no
blocking for UDP, for example; and if you're using TCP without
FNONBLOCK set, you can hang if the remote end has advertised a zero
window for transmission).
The higher level APIs may provide a more coherent view of this.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | If you're not confused,
| You're not paying attention
*--------------------------------------*-------------------------------*
_______________________________________________
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.