Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

64 lines (50 sloc) 0.924 kB
#include <stdint.h>
#include <stdlib.h>
#include <sys/socket.h>
#include "dat.h"
void
srv(Srv *s)
{
int r;
sockinit((Handle)srvtick, s, 10*1000000); // 10ms
s->sock.x = s;
s->sock.f = (Handle)srvaccept;
s->conns.cap = 0;
s->conns.len = 0;
s->conns.data = NULL;
s->conns.less = (Less)connless;
s->conns.rec = (Record)connrec;
r = listen(s->sock.fd, 1024);
if (r == -1) {
twarn("listen");
return;
}
r = sockwant(&s->sock, 'r');
if (r == -1) {
twarn("sockwant");
exit(2);
}
sockmain();
twarnx("sockmain");
exit(1);
}
void
srvschedconn(Srv *s, conn c)
{
if (c->tickpos > -1) {
heapremove(&s->conns, c->tickpos);
}
if (c->tickat) {
heapinsert(&s->conns, c);
}
}
void
srvaccept(Srv *s, int ev)
{
h_accept(s->sock.fd, ev, s);
}
void
srvtick(Srv *s, int ev)
{
prottick(s);
}
Jump to Line
Something went wrong with that request. Please try again.