FreeBSD/contrib/telnet/telnet/network.c
/*
 *  netflush
 *		Send as much data as possible to the network,
 *	handling requests for urgent data.
 *
 *		The return value indicates whether we did any
 *	useful work.
 */
netflush
Send as much data as possible to the network,
handling requests for urgent data.

The return value indicates whether we did any
useful work.
netflush Send as much data as possible to the network handling requests for urgent data . The return value indicates whether we did any useful work .
int
netflush(void)
{
    int n, n1;
#ifdef	ENCRYPTION
    if (encrypt_output)
	ring_encrypt(&netoring, encrypt_output);
#endif	
    if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
	if (!ring_at_mark(&netoring)) {
	    n = send(net, (char *)netoring.consume, n, 0); 
	} else {
	    n = send(net, (char *)netoring.consume, 1, MSG_OOB);
	}
    }
    if (n < 0) {
	if (errno != ENOBUFS && errno != EWOULDBLOCK) {
	    setcommandmode();
	    perror(hostname);
	    (void)NetClose(net);
	    ring_clear_mark(&netoring);
	    ExitString("Connection closed by foreign host.\n", 1);
	}
	n = 0;
    }
    if (netdata && n) {
	Dump('>', netoring.consume, n);
    }
    if (n) {
	ring_consumed(&netoring, n);
	if ((n1 == n) && ring_full_consecutive(&netoring)) {
	    (void) netflush();
	}
	return 1;
    } else {
	return 0;
    }
}
int netflush ( void ) { int n , n1 ; #ifdef ENCRYPTION if ( encrypt_output ) ring_encrypt ( & netoring , encrypt_output ) ; #endif if ( ( n1 = n = ring_full_consecutive ( & netoring ) ) > 0 ) { if ( ! ring_at_mark ( & netoring ) ) { n = send ( net , ( char * ) netoring . consume , n , 0 ) ; } else { n = send ( net , ( char * ) netoring . consume , 1 , MSG_OOB ) ; } } if ( n < 0 ) { if ( errno != ENOBUFS && errno != EWOULDBLOCK ) { setcommandmode ( ) ; perror ( hostname ) ; ( void ) NetClose ( net ) ; ring_clear_mark ( & netoring ) ; ExitString ( " \n " , 1 ) ; } n = 0 ; } if ( netdata && n ) { Dump ( ' ' , netoring . consume , n ) ; } if ( n ) { ring_consumed ( & netoring , n ) ; if ( ( n1 == n ) && ring_full_consecutive ( & netoring ) ) { ( void ) netflush ( ) ; } return 1 ; } else { return 0 ; } }
netflush
              Send as much data as possible to the network,
      handling requests for urgent data.
netflush Send as much data as possible to the network handling requests for urgent data .
/* ENCRYPTION */ /* 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).
	     */ /* URGENT data */ /*NOTREACHED*/ /*
	 * If we sent all, and more to send, then recurse to pick
	 * up the other half.
	 */