Skip to content
Snippets Groups Projects
Commit 0373cacb authored by rswindell's avatar rswindell
Browse files

putcom():

Don't make a blocking-call to send/sendsocket() without first checking
writability with select().
parent 417143ae
No related branches found
No related tags found
No related merge requests found
......@@ -46,15 +46,24 @@ static int lprintf(int level, const char *fmt, ...)
void putcom(char* buf, size_t len)
{
char str[128];
char* p=str;
size_t i;
for(i=0;i<len;i++)
p+=sprintf(p,"%u ", ((BYTE)buf[i]));
lprintf(LOG_DEBUG,"TX: %s", str);
send(telnet_sock, buf, len, 0);
fd_set wds;
FD_ZERO(&wds);
FD_SET(telnet_sock, &wds);
struct timeval tv;
tv.tv_sec=0;
tv.tv_usec=1000;
if(select(telnet_sock+1, NULL, &wds, NULL, &tv) == 1) {
char str[128];
char* p=str;
size_t i;
for(i=0;i<len;i++)
p+=sprintf(p,"%u ", ((BYTE)buf[i]));
lprintf(LOG_DEBUG,"TX: %s", str);
sendsocket(telnet_sock, buf, len);
} else
lprintf(LOG_WARNING, "TX: putcom(%d) timeout", len);
}
static void send_telnet_cmd(uchar cmd, uchar opt)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment