32 sockwant(Socket
*s
, int rw
)
35 struct kevent evs
[2] = {{0}};
36 struct kevent
*ev
= evs
;
37 struct timespec ts
= {.tv_sec
= 0, .tv_nsec
= 0};
41 ev
->filter
= s
->added
;
42 ev
->flags
= EV_DELETE
;
51 ev
->filter
= EVFILT_READ
;
54 ev
->filter
= EVFILT_WRITE
;
57 // check only for hangup
58 ev
->filter
= EVFILT_READ
;
59 ev
->fflags
= NOTE_LOWAT
;
64 s
->added
= ev
->filter
;
69 return kevent(kq
, evs
, n
, NULL
, 0, &ts
);
74 socknext(Socket
**s
, int64 timeout
)
78 static struct timespec ts
;
80 ts
.tv_sec
= timeout
/ 1000000000;
81 ts
.tv_nsec
= timeout
% 1000000000;
82 r
= kevent(kq
, NULL
, 0, &ev
, 1, &ts
);
83 if (r
== -1 && errno
!= EINTR
) {
90 if (ev
.flags
& EV_EOF
) {