* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)network.c 1.13 (Berkeley) 6/29/88";
char netobuf
[2*BUFSIZ
], netibuf
[BUFSIZ
];
* Initialize internal network data structures.
if (ring_init(&netoring
, netobuf
, sizeof netobuf
) != 1) {
if (ring_init(&netiring
, netibuf
, sizeof netibuf
) != 1) {
* 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
)) {