summaryrefslogtreecommitdiffstats
path: root/socket_tcp.c
blob: 5a7c920ea7aeb780965fe6dd27afffd4ea195db6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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;
}