* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
static char sccsid
[] = "@(#)network.c 1.11 (Berkeley) 3/8/88";
char netobuf
[2*BUFSIZ
], netibuf
[BUFSIZ
];
* Initialize internal network data structures.
ring_init(&netoring
, netobuf
, sizeof netobuf
);
ring_init(&netiring
, netibuf
, sizeof netibuf
);
* Check to see if any out-of-band data exists on a socket (for
* Telnet "synch" processing).
static struct timeval timeout
= { 0 };
value
= select(net
+1, (fd_set
*)0, (fd_set
*)0, &excepts
, &timeout
);
} while ((value
== -1) && (errno
== EINTR
));
if (FD_ISSET(net
, &excepts
)) {
* Sets "neturg" to the current location.
* Send as much data as possible to the network,
* handling requests for urgent data.
* The return value indicates whether we did any
if ((n1
= n
= ring_full_consecutive(&netoring
)) > 0) {
if (!ring_at_mark(&netoring
)) {
n
= send(net
, netoring
.consume
, n
, 0); /* normal write */
* In 4.2 (and 4.3) systems, there is some question about
* what byte in a sendOOB operation is the "OOB" data.
* To make ourselves compatible, we only send ONE byte
* out of band, the one WE THINK should be OOB (though
* we really have more the TCP philosophy of urgent data
* rather than the Unix philosophy of OOB data).
n
= send(net
, netoring
.consume
, 1, MSG_OOB
);/* URGENT data */
if (errno
!= ENOBUFS
&& errno
!= EWOULDBLOCK
) {
ring_clear_mark(&netoring
);
Dump('>', netoring
.consume
, n
);
ring_consumed(&netoring
, n
);
* If we sent all, and more to send, then recurse to pick
if ((n1
== n
) && ring_full_consecutive(&netoring
)) {