summaryrefslogtreecommitdiff
path: root/src/socket_tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket_tcp.c')
-rw-r--r--src/socket_tcp.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/socket_tcp.c b/src/socket_tcp.c
index 1ff050e..70ada37 100644
--- a/src/socket_tcp.c
+++ b/src/socket_tcp.c
@@ -1,15 +1,17 @@
-#include <sys/types.h>
+#include <netinet/in.h>
#include <sys/param.h>
#include <sys/socket.h>
-#include <netinet/in.h>
+#include <sys/types.h>
+
#include <errno.h>
-#include "close.h" /* better use unistd.h ? */
+
+#include "close.h" /* better use unistd.h ? */
+#include "error.h"
#include "ndelay.h"
#include "socket_if.h"
-#include "error.h"
#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT EINVAL
+ #define EAFNOSUPPORT EINVAL
#endif
/**
@@ -23,9 +25,12 @@ int socket_tcp4(void)
{
int s;
- s = socket(AF_INET,SOCK_STREAM,0);
- if (s != -1)
- if (ndelay_on(s) == -1) { close(s); return -1; }
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s != -1)
+ if (ndelay_on(s) == -1) {
+ close(s);
+ return -1;
+ }
return s;
}
@@ -34,9 +39,12 @@ int socket_tcp6(void)
{
int s;
- s = socket(AF_INET6,SOCK_STREAM,0);
- if (s != -1)
- if (ndelay_on(s) == -1) { close(s); return -1; }
+ s = socket(AF_INET6, SOCK_STREAM, 0);
+ if (s != -1)
+ if (ndelay_on(s) == -1) {
+ close(s);
+ return -1;
+ }
return s;
}
@@ -45,13 +53,16 @@ int socket_tcp(void)
{
int s;
- s = socket(AF_INET6,SOCK_STREAM,0);
- if (s == -1)
- if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPROTO || errno == EPROTONOSUPPORT)
- s = socket(AF_INET,SOCK_STREAM,0);
+ s = socket(AF_INET6, SOCK_STREAM, 0);
+ if (s == -1)
+ if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPROTO || errno == EPROTONOSUPPORT)
+ s = socket(AF_INET, SOCK_STREAM, 0);
- if (s != -1)
- if (ndelay_on(s) == -1) { close(s); return -1; }
+ if (s != -1)
+ if (ndelay_on(s) == -1) {
+ close(s);
+ return -1;
+ }
return s;
}
@@ -59,5 +70,5 @@ int socket_tcp(void)
int socket_tcpnodelay(int s)
{
int opt = 1;
- return setsockopt(s,IPPROTO_TCP,1,&opt,sizeof(opt)); /* 1 == TCP_NODELAY */
+ return setsockopt(s, IPPROTO_TCP, 1, &opt, sizeof(opt)); /* 1 == TCP_NODELAY */
}