EIO_Status CSocket::Write(const void* buf, size_t size, size_t* n_written, EIO_WriteMethod how) { if ( m_Socket ) return SOCK_Write(m_Socket, buf, size, n_written, how); if ( n_written ) *n_written = 0; return eIO_Closed; }
static EIO_Status s_VT_Write (CONNECTOR connector, const void* buf, size_t size, size_t* n_written, const STimeout* timeout) { SSockConnector* xxx = (SSockConnector*) connector->handle; assert(xxx->sock); verify(SOCK_SetTimeout(xxx->sock, eIO_Write, timeout) == eIO_Success); return SOCK_Write(xxx->sock, buf, size, n_written, eIO_WritePlain); }
static int/*bool*/ s_SockWrite(SOCK sock, const char* buf, size_t len) { size_t n; if (!len) len = strlen(buf); if (SOCK_Write(sock, buf, len, &n, eIO_WritePersist) == eIO_Success && n == len) { return 1/*success*/; } return 0/*failure*/; }
/* Connect to the server specified by uuu->net_info, then compose and form * relevant HTTP header, and flush the accumulated output data(uuu->w_buf) * after the HTTP header. If connection/write unsuccessful, retry to reconnect * and send the data again until permitted by s_Adjust(). */ static EIO_Status s_ConnectAndSend(SHttpConnector* uuu, EReadMode read_mode) { EIO_Status status; for (;;) { char* null = 0; if (!uuu->sock) { if ((status = s_Connect(uuu, read_mode)) != eIO_Success) break; assert(uuu->sock); uuu->read_header = 1/*true*/; uuu->shut_down = 0/*false*/; uuu->expected = 0; uuu->received = 0; uuu->code = 0; } else status = eIO_Success; if (uuu->w_len) { size_t off = BUF_Size(uuu->w_buf) - uuu->w_len; SOCK_SetTimeout(uuu->sock, eIO_Write, uuu->w_timeout); do { char buf[4096]; size_t n_written; size_t n_write = BUF_PeekAt(uuu->w_buf, off, buf, sizeof(buf)); status = SOCK_Write(uuu->sock, buf, n_write, &n_written, eIO_WritePlain); if (status != eIO_Success) break; uuu->w_len -= n_written; off += n_written; } while (uuu->w_len); } else if (!uuu->shut_down) status = SOCK_Write(uuu->sock, 0, 0, 0, eIO_WritePlain); if (status == eIO_Success) { assert(uuu->w_len == 0); if (!uuu->shut_down) { /* 10/07/03: While this call here is perfectly legal, it could * cause connection severed by a buggy CISCO load-balancer. */ /* 10/28/03: CISCO's beta patch for their LB shows that the * problem has been fixed; no more 2'30" drops in connections * that shut down for write. We still leave this commented * out to allow unpatched clients to work seamlessly... */ /*SOCK_Shutdown(uuu->sock, eIO_Write);*/ uuu->shut_down = 1; } break; } if (status == eIO_Timeout && uuu->w_timeout && !(uuu->w_timeout->sec | uuu->w_timeout->usec)) { break; } CORE_LOGF_X(6, eLOG_Error, ("[HTTP] Error writing body at offset %lu (%s)", (unsigned long)(BUF_Size(uuu->w_buf) - uuu->w_len), IO_StatusStr(status))); /* write failed; close and try to use another server */ SOCK_Abort(uuu->sock); s_DropConnection(uuu, 0/*no wait*/); if (!s_Adjust(uuu, &null, read_mode)) { uuu->can_connect = eCC_None; status = eIO_Closed; break; } } return status; }
static void TEST__client_1(SOCK sock) { EIO_Status status; size_t n_io, n_io_done; char buf[TEST_BUFSIZE]; CORE_LOG(eLOG_Note, "TEST__client_1(TC1)"); /* Send a short string */ SOCK_SetDataLoggingAPI(eOn); {{ const char* x_C1 = s_C1; n_io = strlen(x_C1) + 1; status = SOCK_Write(sock, x_C1, n_io, &n_io_done, eIO_WritePersist); }} assert(status == eIO_Success && n_io == n_io_done); /* Read the string back (it must be bounced by the server) */ SOCK_SetDataLoggingAPI(eOff); SOCK_SetDataLogging(sock, eOn); n_io = strlen(s_S1) + 1; status = SOCK_Read(sock, buf, n_io, &n_io_done, eIO_ReadPeek); status = SOCK_Read(sock, buf, n_io, &n_io_done, eIO_ReadPlain); if (status == eIO_Closed) CORE_LOG(eLOG_Fatal, "TC1:: connection closed"); assert(status == eIO_Success && n_io == n_io_done); assert(strcmp(buf, s_S1) == 0); assert(SOCK_PushBack(sock, buf, n_io_done) == eIO_Success); memset(buf, '\xFF', n_io_done); assert(SOCK_Read(sock, buf, n_io_done, &n_io_done, eIO_ReadPlain) == eIO_Success); assert(SOCK_Status(sock, eIO_Read) == eIO_Success); assert(strcmp(buf, s_S1) == 0); SOCK_SetDataLogging(sock, eDefault); /* Send a very big binary blob */ {{ size_t i; unsigned char* blob = (unsigned char*) malloc(BIG_BLOB_SIZE); for (i = 0; i < BIG_BLOB_SIZE; blob[i] = (unsigned char) i, i++) continue; for (i = 0; i < 10; i++) { status = SOCK_Write(sock, blob + i * SUB_BLOB_SIZE, SUB_BLOB_SIZE, &n_io_done, eIO_WritePersist); assert(status == eIO_Success && n_io_done==SUB_BLOB_SIZE); } free(blob); }} /* Send a very big binary blob with read on write */ /* (it must be bounced by the server) */ {{ size_t i; unsigned char* blob = (unsigned char*) malloc(BIG_BLOB_SIZE); SOCK_SetReadOnWrite(sock, eOn); for (i = 0; i < BIG_BLOB_SIZE; blob[i] = (unsigned char) i, i++) continue; for (i = 0; i < 10; i++) { status = SOCK_Write(sock, blob + i * SUB_BLOB_SIZE, SUB_BLOB_SIZE, &n_io_done, eIO_WritePersist); assert(status == eIO_Success && n_io_done == SUB_BLOB_SIZE); } /* Receive back a very big binary blob, and check its content */ memset(blob,0,BIG_BLOB_SIZE); for (i = 0; i < 10; i++) { status = SOCK_Read(sock, blob + i * SUB_BLOB_SIZE, SUB_BLOB_SIZE, &n_io_done, eIO_ReadPersist); assert(status == eIO_Success && n_io_done == SUB_BLOB_SIZE); } for (n_io = 0; n_io < BIG_BLOB_SIZE; n_io++) assert(blob[n_io] == (unsigned char) n_io); free(blob); }} /* Try to read more data (must hit EOF as the peer is shut down) */ assert(SOCK_Read(sock, buf, 1, &n_io_done, eIO_ReadPeek) == eIO_Closed); assert(SOCK_Status(sock, eIO_Read) == eIO_Closed); assert(SOCK_Read(sock, buf, 1, &n_io_done, eIO_ReadPlain) == eIO_Closed); assert(SOCK_Status(sock, eIO_Read) == eIO_Closed); /* Shutdown on read */ assert(SOCK_Shutdown(sock, eIO_Read) == eIO_Success); assert(SOCK_Status (sock, eIO_Write) == eIO_Success); assert(SOCK_Status (sock, eIO_Read) == eIO_Closed); assert(SOCK_Read (sock, 0, 0, &n_io_done, eIO_ReadPlain) == eIO_Closed); assert(SOCK_Read (sock, 0, 0, &n_io_done, eIO_ReadPeek) == eIO_Closed); assert(SOCK_Status (sock, eIO_Read) == eIO_Closed); assert(SOCK_Status (sock, eIO_Write) == eIO_Success); assert(SOCK_Read (sock, buf, 1,&n_io_done,eIO_ReadPlain) == eIO_Closed); assert(SOCK_Read (sock, buf, 1,&n_io_done,eIO_ReadPeek) == eIO_Closed); assert(SOCK_Status (sock, eIO_Read) == eIO_Closed); assert(SOCK_Status (sock, eIO_Write) == eIO_Success); /* Shutdown on write */ assert(SOCK_Shutdown(sock, eIO_Write) == eIO_Success); assert(SOCK_Status (sock, eIO_Write) == eIO_Closed); assert(SOCK_Write (sock, 0, 0, &n_io_done, eIO_WritePersist) == eIO_Closed); assert(SOCK_Status (sock, eIO_Write) == eIO_Closed); assert(SOCK_Write (sock, buf, 1, &n_io_done, eIO_WritePersist) == eIO_Closed); assert(SOCK_Status (sock, eIO_Write) == eIO_Closed); /* Double shutdown should be okay */ assert(SOCK_Shutdown(sock, eIO_Read) == eIO_Success); assert(SOCK_Shutdown(sock, eIO_ReadWrite) == eIO_Success); assert(SOCK_Shutdown(sock, eIO_Write) == eIO_Success); assert(SOCK_Status (sock, eIO_Read) == eIO_Closed); assert(SOCK_Status (sock, eIO_Write) == eIO_Closed); assert(SOCK_Status (sock, eIO_ReadWrite) == eIO_InvalidArg); }
static void TEST__server_2(SOCK sock, LSOCK lsock) { EIO_Status status; size_t n_io, n_io_done; char buf[TEST_BUFSIZE]; STimeout r_to, w_to, rc_to; size_t i; CORE_LOG(eLOG_Note, "TEST__server_2(TS2)"); r_to.sec = 0; r_to.usec = 0; w_to = r_to; rc_to.sec = 30; rc_to.usec = 123456; /* goto */ l_reconnect: /* reconnection loopback */ SOCK_SetDataLogging(sock, eOn); status = SOCK_SetTimeout(sock, eIO_Read, &r_to); assert(status == eIO_Success); status = SOCK_SetTimeout(sock, eIO_Write, &w_to); assert(status == eIO_Success); for (i = 0; ; i++) { char* x_buf; /* read data from socket */ n_io = sizeof(buf); status = SOCK_Read(sock, buf, n_io, &n_io_done, eIO_ReadPlain); switch ( status ) { case eIO_Success: CORE_LOGF(eLOG_Note, ("TS2::read:" " [%lu], status=%7s, n_io=%5lu, n_io_done=%5lu", (unsigned long)i, IO_StatusStr(status), (unsigned long)n_io, (unsigned long)n_io_done)); assert(n_io_done > 0); break; case eIO_Closed: CORE_LOG(eLOG_Note, "TS2::read: connection closed"); assert(SOCK_Status(sock, eIO_Read) == eIO_Closed); /* close connection */ status = SOCK_Close(sock); assert(status == eIO_Success || status == eIO_Closed); /* reconnect */ if ( !lsock ) return; CORE_LOG(eLOG_Note, "TS2::reconnect"); if ((status = LSOCK_Accept(lsock, &rc_to, &sock)) != eIO_Success) return; assert(SOCK_Status(sock, eIO_Read) == eIO_Success); /* !!! */ goto l_reconnect; case eIO_Timeout: CORE_LOGF(eLOG_Note, ("TS2::read:" " [%lu] timeout expired: %5u sec, %6u usec", (unsigned long)i, r_to.sec, r_to.usec)); assert(n_io_done == 0); s_DoubleTimeout(&r_to); status = SOCK_SetTimeout(sock, eIO_Read, &r_to); assert(status == eIO_Success); assert(SOCK_Status(sock, eIO_Read) == eIO_Timeout); break; default: CORE_LOGF(eLOG_Fatal, ("TS2::read: status = %d", (int) status)); } /* switch */ /* write(just the same) data back to client */ n_io = n_io_done; x_buf = buf; while ( n_io ) { status = SOCK_Write(sock, buf, n_io, &n_io_done, eIO_WritePersist); switch ( status ) { case eIO_Success: CORE_LOGF(eLOG_Note, ("TS2::write:" " [%lu], status=%7s, n_io=%5lu, n_io_done=%5lu", (unsigned long)i, IO_StatusStr(status), (unsigned long)n_io, (unsigned long)n_io_done)); assert(n_io_done > 0); break; case eIO_Closed: CORE_LOG(eLOG_Fatal, "TS2::write: connection closed"); return; case eIO_Timeout: CORE_LOGF(eLOG_Note, ("TS2::write:" " [%lu] timeout expired: %5u sec, %6u usec", (unsigned long)i, w_to.sec, w_to.usec)); assert(n_io_done == 0); s_DoubleTimeout(&w_to); status = SOCK_SetTimeout(sock, eIO_Write, &w_to); assert(status == eIO_Success); break; default: CORE_LOGF(eLOG_Fatal, ("TS2::write: status = %d", (int) status)); } /* switch */ n_io -= n_io_done; x_buf += n_io_done; } } }
static void TEST__client_2(SOCK sock) { #define W_FIELD 10 #define N_FIELD 1000 #define N_REPEAT 10 #define N_RECONNECT 3 EIO_Status status; size_t n_io, n_io_done, i; char buf[W_FIELD * N_FIELD + 1]; CORE_LOGF(eLOG_Note, ("TEST__client_2(TC2) @:%hu", SOCK_GetLocalPort(sock, eNH_HostByteOrder))); /* fill out a buffer to send to server */ memset(buf, 0, sizeof(buf)); for (i = 0; i < N_FIELD; i++) { sprintf(buf + i * W_FIELD, "%10lu", (unsigned long)i); } /* send the buffer to server, then get it back */ for (i = 0; i < N_REPEAT; i++) { char buf1[sizeof(buf)]; STimeout w_to, r_to; int/*bool*/ w_timeout_on = (int)(i%2); /* if to start from */ int/*bool*/ r_timeout_on = (int)(i%2); /* zero or inf. timeout */ char* x_buf; /* set timeout */ w_to.sec = 0; w_to.usec = 0; status = SOCK_SetTimeout(sock, eIO_Write, w_timeout_on ? &w_to : 0); assert(status == eIO_Success); /* reconnect */ if ((i % N_RECONNECT) == 0) { size_t j = i / N_RECONNECT; do { SOCK_SetDataLogging(sock, eOn); status = SOCK_Reconnect(sock, 0, 0, 0); SOCK_SetDataLogging(sock, eDefault); CORE_LOGF(eLOG_Note, ("TC2::reconnect @:%hu: i=%lu, j=%lu, status=%s", SOCK_GetLocalPort(sock, eNH_HostByteOrder), (unsigned long) i, (unsigned long) j, IO_StatusStr(status))); assert(status == eIO_Success); assert(SOCK_Status(sock, eIO_Read) == eIO_Success); assert(SOCK_Status(sock, eIO_Write) == eIO_Success); /* give a break to let server reset the listening socket */ X_SLEEP(1); } while ( j-- ); } /* send */ x_buf = buf; n_io = sizeof(buf); do { X_SLEEP(1); status = SOCK_Write(sock, x_buf, n_io, &n_io_done, eIO_WritePersist); if (status == eIO_Closed) CORE_LOG(eLOG_Fatal, "TC2::write: connection closed"); CORE_LOGF(eLOG_Note, ("TC2::write:" " i=%d, status=%7s, n_io=%5lu, n_io_done=%5lu" " timeout(%d): %5u.%06us", (int) i, IO_StatusStr(status), (unsigned long) n_io, (unsigned long) n_io_done, (int) w_timeout_on, w_to.sec, w_to.usec)); if ( !w_timeout_on ) { assert(status == eIO_Success && n_io_done == n_io); } else { const STimeout* x_to; assert(status == eIO_Success || status == eIO_Timeout); x_to = SOCK_GetTimeout(sock, eIO_Write); assert(w_to.sec == x_to->sec && w_to.usec == x_to->usec); } n_io -= n_io_done; x_buf += n_io_done; if (status == eIO_Timeout) s_DoubleTimeout(&w_to); status = SOCK_SetTimeout(sock, eIO_Write, &w_to); assert(status == eIO_Success); w_timeout_on = 1/*true*/; } while ( n_io ); /* get back the just sent data */ r_to.sec = 0; r_to.usec = 0; status = SOCK_SetTimeout(sock, eIO_Read, r_timeout_on ? &r_to : 0); assert(status == eIO_Success); x_buf = buf1; n_io = sizeof(buf1); do { if (i%2 == 0) { /* peek a little piece twice and compare */ char xx_buf1[128], xx_buf2[128]; size_t xx_io_done1, xx_io_done2; if (SOCK_Read(sock, xx_buf1, sizeof(xx_buf1), &xx_io_done1, eIO_ReadPeek) == eIO_Success && SOCK_Read(sock, xx_buf2, xx_io_done1, &xx_io_done2, eIO_ReadPeek) == eIO_Success) { assert(xx_io_done1 >= xx_io_done2); assert(memcmp(xx_buf1, xx_buf2, xx_io_done2) == 0); } } status = SOCK_Read(sock, x_buf, n_io, &n_io_done, eIO_ReadPlain); if (status == eIO_Closed) { assert(SOCK_Status(sock, eIO_Read) == eIO_Closed); CORE_LOG(eLOG_Fatal, "TC2::read: connection closed"); } CORE_LOGF(eLOG_Note, ("TC2::read: " " i=%d, status=%7s, n_io=%5lu, n_io_done=%5lu" " timeout(%d): %5u.%06us", (int) i, IO_StatusStr(status), (unsigned long) n_io, (unsigned long) n_io_done, (int) r_timeout_on, r_to.sec, r_to.usec)); if ( !r_timeout_on ) { assert(status == eIO_Success && n_io_done > 0); } else { const STimeout* x_to; assert(status == eIO_Success || status == eIO_Timeout); x_to = SOCK_GetTimeout(sock, eIO_Read); assert(r_to.sec == x_to->sec && r_to.usec == x_to->usec); } n_io -= n_io_done; x_buf += n_io_done; if (status == eIO_Timeout) s_DoubleTimeout(&r_to); status = SOCK_SetTimeout(sock, eIO_Read, &r_to); assert(status == eIO_Success); r_timeout_on = 1/*true*/; } while ( n_io ); assert(memcmp(buf, buf1, sizeof(buf)) == 0); } }
static void TEST__server_1(SOCK sock) { EIO_Status status; size_t n_io, n_io_done; char buf[TEST_BUFSIZE]; CORE_LOG(eLOG_Note, "TEST__server_1(TS1)"); /* Receive and send back a short string */ SOCK_SetDataLogging(sock, eOn); n_io = strlen(s_C1) + 1; status = SOCK_Read(sock, buf, n_io, &n_io_done, eIO_ReadPlain); assert(status == eIO_Success && n_io == n_io_done); assert(strcmp(buf, s_C1) == 0 || strcmp(buf, s_M1) == 0); SOCK_SetDataLogging(sock, eDefault); SOCK_SetDataLoggingAPI(eOn); n_io = strlen(s_S1) + 1; status = SOCK_Write(sock, s_S1, n_io, &n_io_done, eIO_WritePersist); assert(status == eIO_Success && n_io == n_io_done); SOCK_SetDataLoggingAPI(eOff); /* Receive a very big binary blob, and check its content */ {{ #define DO_LOG_SIZE 300 #define DONT_LOG_SIZE BIG_BLOB_SIZE - DO_LOG_SIZE unsigned char* blob = (unsigned char*) malloc(BIG_BLOB_SIZE); status = SOCK_Read(sock,blob,DONT_LOG_SIZE,&n_io_done,eIO_ReadPersist); assert(status == eIO_Success && n_io_done == DONT_LOG_SIZE); SOCK_SetDataLogging(sock, eOn); status = SOCK_Read(sock, blob + DONT_LOG_SIZE, DO_LOG_SIZE, &n_io_done, eIO_ReadPersist); assert(status == eIO_Success && n_io_done == DO_LOG_SIZE); SOCK_SetDataLogging(sock, eDefault); for (n_io = 0; n_io < BIG_BLOB_SIZE; n_io++) assert(blob[n_io] == (unsigned char) n_io); free(blob); }} /* Receive a very big binary blob, and write data back */ {{ unsigned char* blob = (unsigned char*) malloc(BIG_BLOB_SIZE); int i; for (i = 0; i < 10; i++) { /* X_SLEEP(1);*/ status = SOCK_Read(sock, blob + i * SUB_BLOB_SIZE, SUB_BLOB_SIZE, &n_io_done, eIO_ReadPersist); assert(status == eIO_Success && n_io_done == SUB_BLOB_SIZE); status = SOCK_Write(sock, blob + i * SUB_BLOB_SIZE, SUB_BLOB_SIZE, &n_io_done, eIO_WritePersist); assert(status == eIO_Success && n_io_done == SUB_BLOB_SIZE); } for (n_io = 0; n_io < BIG_BLOB_SIZE; n_io++) assert(blob[n_io] == (unsigned char) n_io); free(blob); }} /* Shutdown on write */ #ifdef NCBI_OS_MSWIN assert(SOCK_Shutdown(sock, eIO_ReadWrite) == eIO_Success); #else assert(SOCK_Shutdown(sock, eIO_Write) == eIO_Success); #endif assert(SOCK_Status (sock, eIO_Write) == eIO_Closed); assert(SOCK_Write (sock, 0, 0, &n_io_done, eIO_WritePersist) == eIO_Closed); assert(SOCK_Status (sock, eIO_Write) == eIO_Closed); #ifdef NCBI_OS_MSWIN assert(SOCK_Status (sock, eIO_Read) == eIO_Closed); #else assert(SOCK_Status (sock, eIO_Read) == eIO_Success); #endif assert(SOCK_Close (sock) == eIO_Success); }
int main(int argc, char** argv) { /* Prepare to connect: parse and check cmd.-line args, etc. */ const char* host = argc > 1 ? argv[1] : ""; unsigned short port = argc > 2 ? atoi(argv[2]) : CONN_PORT_HTTP; const char* path = argc > 3 ? argv[3] : ""; const char* args = argc > 4 ? argv[4] : ""; const char* inp_file = argc > 5 ? argv[5] : ""; const char* user_header = argc > 6 ? argv[6] : ""; size_t content_length; STimeout timeout; SOCK sock; EIO_Status status; char buffer[10000]; CORE_SetLOGFormatFlags(fLOG_None | fLOG_Level | fLOG_OmitNoteLevel | fLOG_DateTime); CORE_SetLOGFILE(stderr, 0/*false*/); SOCK_SetupSSL(NcbiSetupTls); fprintf(stderr, "Running...\n" " Executable: '%s'\n" " URL host: '%s'\n" " URL port: %hu\n" " URL path: '%s'\n" " URL args: '%s'\n" " Input data file: '%s'\n" " User header: '%s'\n" "Response(if any) from the hit URL goes to standard output.\n\n", argv[0], host, port, path, args, inp_file, user_header); if ( argc < 4 ) { fprintf(stderr, "Usage: %s host port path args inp_file [user_header]\n", argv[0]); CORE_LOG(eLOG_Fatal, "Two few arguments"); return 1; } {{ FILE *fp = fopen(inp_file, "rb"); long offset; if ( !fp ) { CORE_LOGF(eLOG_Fatal, ("Non-existent file '%s'", inp_file)); return 2; } if ( fseek(fp, 0, SEEK_END) != 0 || (offset = ftell(fp)) < 0 ) { CORE_LOGF(eLOG_Fatal, ("Cannot obtain size of file '%s'", inp_file)); return 2; } fclose(fp); content_length = (size_t) offset; }} timeout.sec = 10; timeout.usec = 0; /* Connect */ sock = URL_Connect(host, port, path, args, /*NCBI_FAKE_WARNING*/ eReqMethod_Any, content_length, &timeout, &timeout, user_header, 1/*true*/, port == CONN_PORT_HTTPS ? fSOCK_LogDefault | fSOCK_Secure : fSOCK_LogDefault); if ( !sock ) return 3; {{ /* Pump data from the input file to socket */ FILE* fp = fopen(inp_file, "rb"); if ( !fp ) { CORE_LOGF(eLOG_Fatal, ("Cannot open file '%s' for reading", inp_file)); return 4; } for (;;) { size_t n_written; size_t n_read = fread(buffer, 1, sizeof(buffer), fp); if ( n_read <= 0 ) { if ( content_length ) { CORE_LOGF(eLOG_Fatal, ("Cannot read last %lu bytes from file '%s'", (unsigned long) content_length, inp_file)); return 5; } break; } assert(content_length >= n_read); content_length -= n_read; status = SOCK_Write(sock, buffer, n_read, &n_written, eIO_WritePersist); if ( status != eIO_Success ) { CORE_LOGF(eLOG_Fatal, ("Error writing to socket: %s", IO_StatusStr(status))); return 6; } } fclose(fp); }} /* Read reply from socket, write it to STDOUT */ {{ size_t n_read; for (;;) { status = SOCK_Read(sock, buffer, sizeof(buffer), &n_read, eIO_ReadPlain); if (status != eIO_Success) break; fwrite(buffer, 1, n_read, stdout); } if ( status != eIO_Closed ) { CORE_LOGF(eLOG_Error, ("Read error after %ld byte(s) from socket: %s", (long) content_length, IO_StatusStr(status))); } fprintf(stdout, "\n"); }} /* Success: close the socket, cleanup, and exit */ SOCK_Close(sock); CORE_LOG(eLOG_Note, "TEST completed successfully"); CORE_SetLOG(0); return 0; }
static Int2 LIBCALLBACK s_AsnWrite(Pointer p, CharPtr buff, Uint2 len) { size_t n_written = 0; SOCK_Write((SOCK)p, buff, len, &n_written, eIO_WritePlain); return (Int2)n_written; }