DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦a0c39ae12⟧ TextFile

    Length: 676 (0x2a4)
    Types: TextFile
    Names: »sockio.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Hearts/sockio.c« 

TextFile

#include <stdio.h>
/*
 * Routines to send and receive on sockets.  Four bytes of length are
 * sent, followed by the null terminated string.
 *
 */
read_socket(s, buf)
int	s;			/* socket to talk on */
char	*buf;			/* string to send */
{
	int nbytes;

	if (read(s, (char *) &nbytes, sizeof(int)) != sizeof (int))
		return 0;
	nbytes = ntohl(nbytes);
	if (read(s, buf, nbytes) != nbytes)
		return 0;
	return nbytes;
}


write_socket(s, buf)
int	s;			/* socket to talk on */
char	*buf;			/* string to read on */
{
	int nbytes, netnbytes;

	nbytes = strlen(buf) + 1;
	netnbytes = htonl(nbytes);
	(void) write(s, (char *) &netnbytes, sizeof(int));
	(void) write(s, buf, nbytes);
}