- while sending data, wait relative to the size of the mail /128 + a minimal set of 50.
* sock_write() - send binary to server.
* Returns the number of bytes written, or -1 for error.
*/
-int sock_write(int *sock, const char *buf, int nbytes)
+int sock_write(int *sock, const char *buf, int nbytes)
+{ return sock_write_timeout(sock, buf, nbytes, 50); }
+int sock_write_timeout(int *sock, const char *buf, int nbytes, int timeout)
{
int nSuccessLess = 0;
int bytes_written = 0;
fd_set rfds;
int fdflags;
int IsNonBlock;
- int timeout = 50;
struct timeval tv;
int selectresolution = 100;
int sock_read_to(int *sock, char *buf, int bytes, int timeout, int keep_reading_until_full);
int sock_read(int *sock, char *buf, int bytes, int keep_reading_until_full);
int sock_write(int *sock, const char *buf, int nbytes);
+int sock_write_timeout(int *sock, const char *buf, int nbytes, int timeout);
int ml_sock_gets(int *sock, char *buf, int nSec);
int sock_getln(int *sock, char *buf, int bufsize);
int CtdlSockGetLine(int *sock, StrBuf *Target, int nSec);
}
/* If we reach this point, the server is expecting data.*/
- sock_write(&sock, msgtext, msg_size);
+ sock_write_timeout(&sock,
+ msgtext,
+ msg_size,
+ (msg_size / 128) + 50);
if (msgtext[msg_size-1] != 10) {
CtdlLogPrintf(CTDL_WARNING, "Possible problem: message did not "
"correctly terminate. (expecting 0x10, got 0x%02x)\n",