GsRead(int fd, void *buf, int c) #endif { int e, n; n = 0; while(n < c) { #if !HELLOOS e = read(fd, ((char *)buf) + n, c - n); #else e = bucket_recv(fd, ((char *)buf) + n, c - n); #endif if(e <= 0) { if (e == 0) EPRINTF("nano-X: client closed socket: %d\n", fd); else #if !HELLOOS EPRINTF("nano-X: GsRead failed %d %d: %d\r\n", e, n, errno); #else EPRINTF("nano-X: GsRead failed %d %d: %d\r\n", e, n, e); #endif GsClose(fd); return -1; } n += e; } return 0; }
/* * Close the current connection to the server. */ void GrClose(void) { SERVER_LOCK(); GsClose(current_fd); SERVER_UNLOCK(); }
/* * This is a wrapper to write(). */ int GsWrite(int fd, void *buf, int c) { int e, n; n = 0; while(n < c) { e = write(fd, ((char *) buf + n), (c - n)); if(e <= 0) { GsClose(fd); return -1; } n += e; } return 0; }
/* * This is a wrapper to write(). */ int GsWrite(int fd, void *buf, int c) { int e, n; n = 0; while(n < c) { #if !HELLOOS e = write(fd, ((char *) buf + n), (c - n)); #else e = bucket_send(fd, ((char *) buf + n), (c - n)); #endif if(e <= 0) { GsClose(fd); return -1; } n += e; } return 0; }
GsRead(int fd, void *buf, int c) #endif { int e, n; n = 0; while(n < c) { e = read(fd, (buf + n), (c - n)); if(e <= 0) { if (e == 0) EPRINTF("nano-X: client closed socket: %d\n", fd); else EPRINTF("nano-X: GsRead failed %d %d: %d\r\n", e, n, errno); GsClose(fd); return -1; } n += e; } return 0; }