8#include "timeoutconn.h"
14static struct taia now;
15static struct taia deadline;
17static ssize_t mywrite(
int fd,
char *buf,
int len)
23 x.events = IOPAUSE_WRITE;
26 r = iopause(&x,1,&deadline,&now);
29 if (taia_less(&deadline,&now)) {
34 return write(fd,buf,len);
37static ssize_t
myread(
int fd,
char *buf,
int len)
43 x.events = IOPAUSE_READ;
46 r = iopause(&x,1,&deadline,&now);
49 if (taia_less(&deadline,&now)) {
54 return read(fd,buf,len);
61 char strnum[FMT_ULONG];
66 if (socket_bind4(s,
iplocal,0) == -1)
return -1;
76 buffer_put(&
b,
" , ",3);
77 buffer_put(&
b,strnum,fmt_ulong(strnum,
portlocal));
78 buffer_put(&
b,
"\r\n",2);
79 if (buffer_flush(&
b) == -1)
return -1;
84 if (buffer_get(&
b,&ch,1) != 1)
return -1;
85 if ((ch ==
' ') || (ch ==
'\t') || (ch ==
'\r'))
continue;
86 if (ch ==
'\n')
return 0;
88 if (ch ==
':') ++numcolons;
91 if (!stralloc_append(
out,&ch))
return -1;
92 if (
out->len > 256)
return 0;
102 if (!stralloc_copys(
out,
""))
return -1;
106 taia_add(&deadline,&now,&deadline);
109 if (s == -1)
return -1;
int remoteinfo(stralloc *out, char ipremote[16], uint16 portremote, char iplocal[16], uint16 portlocal, unsigned int timeout, uint32 netif)
ssize_t myread(int fd, char *buf, int len)
char bspace[BUFFER_SMALL]
int read(int, char *, int)
void doit(int fdleft, int fdright)
int write(int, char *, int)