Wojtek Meler writes:
> On Linux you can call
>
> ioctl(fd, TIOCOUTQ, &data_size);
>
> to check if data has been sent. Is it possible in Solaris?
No. First of all, the TIOC* ioctls are for ttys, not sockets, so the
Linux implementation of this is just pure hackery.
There are two Solaris CRs related to this. One is CR 6366458, which
is the usage you're suggesting, and is currently marked as
"incomplete" because it doesn't seem to make sense. The other is CR
4875565, which notes that the ioctl isn't actually implemented by any
tty driver, and either should be supported by them or removed from the
header file.
The reason it doesn't make sense to implement this for sockets is that
there appears to be no good way to do it correctly and, frankly, any
application that attempts to use it is probably doing something that
can be done better some other way.
I can imagine at least three different intended semantics for this
ioctl when used with TCP:
1. It reports all unsent data.
2. It reports all unsent and unacknowledged data.
3. It reports all unsent and unacknowledged data, plus unread data
at the peer's side.
The _only_ usage model I've ever seen for this ioctl is (3) -- but if
you have another, I'd certainly like to know about it, and I'd update
the CR with that information.
Unfortunately, of the options, (3) is impossible to implement. TCP
provides no solid indication that the peer application has read the
data and, more importantly, even if it did do that, that still
wouldn't tell you whether the application had done anything useful
with the data (i.e., committed it to stable storage). In other words,
it doesn't provide the sort of reliable indication that such an
application needs.
The right (and portable and simple and safe) way to do (3) is via
application-level mechanisms. For example, send a "null" or "no-op"
message of some sort and wait for the peer's response. Or, if you're
at the end of a connection, use shutdown(fd, 1) and wait for the peer
to close.
It would be remotely possible, though a bit difficult due to Solaris
architecture, to implement (1) or (2). Unfortunately, I can't see a
usage model in which either value is interesting other than as a raw
statistic. And as a statistic, we certainly need better ways to
expose that sort of connection information than via ioctls.
--
James Carlson, KISS Network <[EMAIL PROTECTED]>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
_______________________________________________
networking-discuss mailing list
[email protected]