epoch fix

This commit is contained in:
Jack Halford 2017-11-19 21:39:13 +01:00
parent 2279ad158e
commit 1bef2f2c68
3 changed files with 5 additions and 5 deletions

View file

@ -42,7 +42,7 @@ int host_format(struct sockaddr *addr);
int create_server(int port, int backlog, char *protoname); int create_server(int port, int backlog, char *protoname);
int create_client(char *addr, int port, char *protoname); int create_client(char *addr, int port, char *protoname);
void listener(int domain, int sock, int proto, void listener(int domain, int sock, int proto,
void (*handler)(void *buf, int bytes, struct sockaddr_in *addr)); void (*handler)(void *buf, int bytes, struct sockaddr *addr));
/* /*
** lazy framing ** lazy framing

View file

@ -30,10 +30,10 @@ int create_client(char *addr, int port, char *protoname)
} }
void listener(int domain, int sock, int proto, void listener(int domain, int sock, int proto,
void (*handler)(void *buf, int bytes, struct sockaddr_in *addr)) void (*handler)(void *buf, int bytes, struct sockaddr *addr))
{ {
int sd; int sd;
struct sockaddr_in addr; struct sockaddr addr;
unsigned char buf[1024]; unsigned char buf[1024];
int bytes; int bytes;
socklen_t len; socklen_t len;
@ -49,7 +49,7 @@ void listener(int domain, int sock, int proto,
{ {
bzero(buf, sizeof(buf)); bzero(buf, sizeof(buf));
bytes = recvfrom(sd, buf, sizeof(buf), 0, bytes = recvfrom(sd, buf, sizeof(buf), 0,
(struct sockaddr*)&addr, &len); &addr, &len);
if (bytes > 0 && handler) if (bytes > 0 && handler)
handler(buf, bytes, &addr); handler(buf, bytes, &addr);
else else

View file

@ -27,5 +27,5 @@ double time_milli(void)
if (gettimeofday(&tv, NULL)) if (gettimeofday(&tv, NULL))
return (0); return (0);
return ((double)((double)tv.tv_sec / 1000. + tv.tv_usec * 1000.)); return ((double)(tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.));
} }