/* anet.c -- Basic TCP socket stuff made a bit less boring
*
- * Copyright (c) 2006-2009, Salvatore Sanfilippo <antirez at gmail dot com>
+ * Copyright (c) 2006-2010, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "fmacros.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
/* Like read(2) but make sure 'count' is read before to return
* (unless error or EOF condition is encountered) */
-int anetRead(int fd, void *buf, int count)
+int anetRead(int fd, char *buf, int count)
{
int nread, totlen = 0;
while(totlen != count) {
/* Like write(2) but make sure 'count' is read before to return
* (unless error is encountered) */
-int anetWrite(int fd, void *buf, int count)
+int anetWrite(int fd, char *buf, int count)
{
int nwritten, totlen = 0;
while(totlen != count) {
close(s);
return ANET_ERR;
}
- if (listen(s, 32) == -1) {
+ if (listen(s, 511) == -1) { /* the magic 511 constant is from nginx */
anetSetError(err, "listen: %s\n", strerror(errno));
close(s);
return ANET_ERR;