RE: Xt Interface?

Steve Lamont (spl@szechuan.ucsd.edu)
Tue, 25 Feb 97 12:24:18 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> > You can try with:
> >
> > void fl_add_io_callback(int fd, unsigned condition, FL_IO_CALLBACK callb
> [...]
> Ok, the only problem I have with this is the fact that when I use this for
> a socket mechanizm and the socket becomes available for writing, even
> though I may not have something to write, this call back will be called
> over and over and over again, is this true? Is there a way to prevent the
> callback from being called unless there is data to actually write to the
> socket?

About the only way I can think of is to only register the callback
when you're ready to write.

In practice, you probably don't need to even register a FL_WRITE
condition. Just register the FL_READ condition and service the socket
for reading. You can generally just write to the socket with impunity
-- I've never had a problem with a write() call blocking for any
significant time.

You can always check the socket with your own select() call if you're
concerned about blocking on write() but I doubt that you'll need to.
My recollection is that the write()s are buffered by the network
software into an mbuf and written as needed by the OS.

By the way, a good reference for network programming is W. Richard
Stevens, _UNIX Network Programming_, Prentice Hall, 1990 (ISBN
0-13-949876-1).

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/