mirror of https://framagit.org/bortzmeyer/echoping
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
434 B
C
25 lines
434 B
C
25 years ago
|
/*
|
||
|
* Write "n" bytes to a descriptor. Use in place of write() when fd is a
|
||
|
* stream socket.
|
||
|
*/
|
||
|
|
||
|
int
|
||
|
writen(fd, ptr, nbytes)
|
||
|
register int fd;
|
||
|
register char *ptr;
|
||
|
register int nbytes;
|
||
|
{
|
||
|
int nleft, nwritten;
|
||
|
|
||
|
nleft = nbytes;
|
||
|
while (nleft > 0) {
|
||
|
nwritten = write(fd, ptr, nleft);
|
||
|
if (nwritten <= 0)
|
||
|
return (nwritten); /* error */
|
||
|
|
||
|
nleft -= nwritten;
|
||
|
ptr += nwritten;
|
||
|
}
|
||
|
return (nbytes - nleft);
|
||
|
}
|