diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
commit | 6c027b4de25a529908be895e7ff19236f4002a57 (patch) | |
tree | f70d3a400bbb9ba8a83e9d4ffcaa4b6e367fc8bb /socket_tcp.c | |
download | crypto-6c027b4de25a529908be895e7ff19236f4002a57.zip crypto-6c027b4de25a529908be895e7ff19236f4002a57.tar.gz |
initial commit, resurrect one of my realy old projects
Diffstat (limited to 'socket_tcp.c')
-rw-r--r-- | socket_tcp.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/socket_tcp.c b/socket_tcp.c new file mode 100644 index 0000000..5a7c920 --- /dev/null +++ b/socket_tcp.c @@ -0,0 +1,16 @@ +#include "socket.h" + +#include <fcntl.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <unistd.h> + +int socket_tcp(int block) +{ + int s; + s = socket(AF_INET,SOCK_STREAM,0); + if (s == -1) return -1; + if(block) return s; + if (fcntl(s,F_SETFL,fcntl(s,F_GETFL,0) | O_NONBLOCK) == -1) { close(s); return -1; } + return s; +} |