7#include "timeoutconn.h"
11static struct taia now;
12static struct taia deadline;
14static ssize_t mywrite(
int fd,
char *
buf,
size_t len)
20 x.events = IOPAUSE_WRITE;
23 r = iopause(&x,1,&deadline,&now);
24 if (r > 0 && x.revents)
break;
25 if (taia_less(&deadline,&now)) {
30 return write(fd,
buf,len);
33static ssize_t myread(
int fd,
char *
buf,
size_t len)
39 x.events = IOPAUSE_READ;
42 r = iopause(&x,1,&deadline,&now);
43 if (r > 0 && x.revents)
break;
44 if (taia_less(&deadline,&now)) {
49 return read(fd,
buf,len);
57 char strnum[FMT_ULONG];
66 buffer_put(&
b,
" , ",3);
67 buffer_put(&
b,strnum,fmt_ulong(strnum,
portlocal));
68 buffer_put(&
b,
"\r\n",2);
69 if (buffer_flush(&
b) == -1)
return -1;
74 if (buffer_get(&
b,&ch,1) != 1)
return -1;
75 if ((ch ==
' ') || (ch ==
'\t') || (ch ==
'\r'))
continue;
76 if (ch ==
'\n')
return 0;
78 if (ch ==
':') ++numcolons;
81 if (!stralloc_append(out,&ch))
return -1;
82 if (out->len > 256)
return 0;
93 if (!stralloc_copys(out,
""))
return -1;
97 taia_add(&deadline,&now,&deadline);
100 if (s == -1)
return -1;
char bspace[BUFFER_SMALL]
int remoteinfo(stralloc *out, char ipremote[16], uint16 portremote, char iplocal[16], uint16 portlocal, unsigned int timeout, uint32 netif)