亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tcpserver.c

?? TCP client and TCP server for Linux!
?? C
字號:
/************tcpserver.c************************/
/* header files needed to use the sockets API */
/* File contain Macro, Data Type and Structure */
/***********************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
/* BufferLength is 100 bytes */
#define BufferLength 100
/* Server port number */
#define SERVPORT 3111

int main()
{
/* Variable and structure definitions. */
int sd, sd2, rc, length = sizeof(int);
int totalcnt = 0, on = 1;
char temp;
char buffer[BufferLength];
struct sockaddr_in serveraddr;
struct sockaddr_in their_addr;

fd_set read_fd;
struct timeval timeout;
timeout.tv_sec = 15;
timeout.tv_usec = 0;


/* The socket() function returns a socket descriptor */
/* representing an endpoint. The statement also */
/* identifies that the INET (Internet Protocol) */
/* address family with the TCP transport (SOCK_STREAM) */
/* will be used for this socket. */
/************************************************/
/* Get a socket descriptor */
if((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
	perror("Server-socket() error");
	/* Just exit */
	exit (-1);
}
else
	printf("Server-socket() is OK\n");

/* The setsockopt() function is used to allow */
/* the local address to be reused when the server */
/* is restarted before the required wait time */
/* expires. */
/***********************************************/
/* Allow socket descriptor to be reusable */
if((rc = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on))) < 0)
{
	perror("Server-setsockopt() error");
	close(sd);
	exit (-1);
}
else
	printf("Server-setsockopt() is OK\n");

/* bind to an address */
memset(&serveraddr, 0x00, sizeof(struct sockaddr_in));
serveraddr.sin_family = AF_INET;
serveraddr.sin_port = htons(SERVPORT);
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);

printf("Using %s, listening at %d\n", inet_ntoa(serveraddr.sin_addr), SERVPORT);
 
/* After the socket descriptor is created, a bind() */
/* function gets a unique name for the socket. */
/* In this example, the user sets the */
/* s_addr to zero, which allows the system to */
/* connect to any client that used port 3005. */
if((rc = bind(sd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) < 0)
{
	perror("Server-bind() error");
	/* Close the socket descriptor */
	close(sd);
	/* and just exit */
	exit(-1);
}
else
	printf("Server-bind() is OK\n");

/* The listen() function allows the server to accept */
/* incoming client connections. In this example, */
/* the backlog is set to 10. This means that the */
/* system can queue up to 10 connection requests before */
/* the system starts rejecting incoming requests.*/
/*************************************************/
/* Up to 10 clients can be queued */
if((rc = listen(sd, 10)) < 0)
{
	perror("Server-listen() error");
	close(sd);
	exit (-1);
}
else
	printf("Server-Ready for client connection...\n");

/* The server will accept a connection request */
/* with this accept() function, provided the */
/* connection request does the following: */
/* - Is part of the same address family */
/* - Uses streams sockets (TCP) */
/* - Attempts to connect to the specified port */
/***********************************************/
/* accept() the incoming connection request. */
int sin_size = sizeof(struct sockaddr_in);
if((sd2 = accept(sd, (struct sockaddr *)&their_addr, &sin_size)) < 0)
{
	perror("Server-accept() error");
	close(sd);
	exit (-1);
}
else
	printf("Server-accept() is OK\n");

/*client IP*/
printf("Server-new socket, sd2 is OK...\n");
printf("Got connection from the f***ing client: %s\n", inet_ntoa(their_addr.sin_addr));

/* The select() function allows the process to */
/* wait for an event to occur and to wake up */
/* the process when the event occurs. In this */
/* example, the system notifies the process */
/* only when data is available to read. */
/***********************************************/
/* Wait for up to 15 seconds on */
/* select() for data to be read. */
FD_ZERO(&read_fd);
FD_SET(sd2, &read_fd);
rc = select(sd2+1, &read_fd, NULL, NULL, &timeout);

if((rc == 1) && (FD_ISSET(sd2, &read_fd)))
{
/* Read data from the client. */
	totalcnt = 0;
	while(totalcnt < BufferLength)
	{

		/* When select() indicates that there is data */
		/* available, use the read() function to read */
		/* 100 bytes of the string that the */
		/* client sent. */
		/***********************************************/
		/* read() from client */
		rc = read(sd2, &buffer[totalcnt], (BufferLength - totalcnt));
		if(rc < 0)
		{
			perror("Server-read() error");
			close(sd);
			close(sd2);
			exit (-1);
		}
		else if (rc == 0)
		{
			printf("Client program has issued a close()\n");
			close(sd);
			close(sd2);
			exit(-1);
		}
		else
		{
			totalcnt += rc;
			printf("Server-read() is OK\n");
		}
	}
}
else if (rc < 0)
{
	perror("Server-select() error");
	close(sd);
	close(sd2);
	exit(-1);
}
/* rc == 0 */
else
{
	printf("Server-select() timed out.\n");
	close(sd);
	close(sd2);
	exit(-1);
}
/* Shows the data */
printf("Received data from the f***ing client: %s\n", buffer);

/* Echo some bytes of string, back */
/* to the client by using the write() */
/* function. */
/************************************/
/* write() some bytes of string, */
/* back to the client. */
printf("Server-Echoing back to client...\n");
rc = write(sd2, buffer, totalcnt);
if(rc != totalcnt)
{
	perror("Server-write() error");
	/* Get the error number. */
	rc = getsockopt(sd2, SOL_SOCKET, SO_ERROR, &temp, &length);

	if(rc == 0)
	{
		/* Print out the asynchronously */
		/* received error. */
		errno = temp;
		perror("SO_ERROR was: ");
	}
	else
		printf("Server-write() is OK\n"); 
		
	close(sd);
	close(sd2);
	exit(-1);
}

 

/* When the data has been sent, close() */
/* the socket descriptor that was returne */
/* from the accept() verb and close() the */
/* original socket descriptor. */
/*****************************************/
/* Close the connection to the client and */
/* close the server listening socket. */
/******************************************/
	close(sd2);
	close(sd);
	exit(0);
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲视频免费在线观看| 国内精品伊人久久久久av一坑| 丝袜美腿亚洲色图| 国产精品一二三区在线| 欧美片在线播放| 最新久久zyz资源站| 国产在线播放一区三区四| 欧美日韩高清影院| 美国三级日本三级久久99| 95精品视频在线| 国产日产欧美精品一区二区三区| 蜜臀av国产精品久久久久| 在线观看亚洲a| 亚洲天天做日日做天天谢日日欢 | 精品国产乱码久久| 亚洲无人区一区| 91捆绑美女网站| 中文欧美字幕免费| 高清不卡在线观看av| 26uuu精品一区二区| 激情综合网av| 欧美一级片免费看| 日本va欧美va欧美va精品| 欧美日韩在线三区| 亚洲图片自拍偷拍| 欧美日韩成人高清| 午夜精品久久久久久| 欧美在线综合视频| 亚洲综合激情另类小说区| 97久久精品人人做人人爽| 国产精品久久久久久久第一福利| 国产凹凸在线观看一区二区| 国产性色一区二区| 成人动漫一区二区三区| 国产欧美日韩精品在线| 国产不卡高清在线观看视频| 国产精品天干天干在观线| 国产成人午夜视频| 国产精品二区一区二区aⅴ污介绍| caoporm超碰国产精品| 一区二区三区在线看| 欧美日产在线观看| 麻豆精品一区二区三区| 久久亚洲一区二区三区四区| 国产成人亚洲综合a∨婷婷图片 | 中文天堂在线一区| 97久久精品人人澡人人爽| 亚洲码国产岛国毛片在线| 91黄色免费观看| 免费人成在线不卡| 久久夜色精品国产噜噜av| www.综合网.com| 日韩精品电影在线观看| 久久青草国产手机看片福利盒子| 成人性色生活片| 亚洲无人区一区| 26uuu国产日韩综合| 国产.欧美.日韩| 亚洲sss视频在线视频| 欧美精品一区二区三区蜜桃 | 国产精品亚洲成人| 亚洲精品国产品国语在线app| 7777精品伊人久久久大香线蕉超级流畅 | 在线成人高清不卡| 国内精品第一页| 亚洲色大成网站www久久九九| 欧美精品丝袜久久久中文字幕| 毛片av中文字幕一区二区| 国产精品久久久久久久久免费丝袜| 91理论电影在线观看| 美女久久久精品| 一区二区三区日韩精品| 精品伦理精品一区| 一道本成人在线| 国产在线精品国自产拍免费| 洋洋av久久久久久久一区| 26uuu亚洲综合色欧美| 日本韩国欧美一区二区三区| 国产一区二区免费视频| 亚洲一区二区三区精品在线| 国产三级精品视频| 日韩久久久精品| 欧美私模裸体表演在线观看| 国产99久久久久久免费看农村| 日韩中文字幕1| 亚洲精品成人在线| 国产精品美女久久久久aⅴ| 日韩欧美成人激情| 欧美日韩一区二区不卡| 99久久国产综合色|国产精品| 精品一区二区三区在线播放 | 91精品国产综合久久香蕉的特点| 波多野结衣一区二区三区| 国内国产精品久久| 久久精品国产精品亚洲红杏 | 成人国产免费视频| 极品销魂美女一区二区三区| 亚洲1区2区3区视频| 亚洲美女视频一区| 亚洲天天做日日做天天谢日日欢 | 亚洲天堂免费在线观看视频| 欧美二区在线观看| 成人av中文字幕| 国产一区二区三区在线观看精品 | 亚洲无线码一区二区三区| 亚洲欧美在线视频观看| 日本一区二区三区久久久久久久久不 | 成人免费高清在线观看| 国产色婷婷亚洲99精品小说| 日韩一区二区精品在线观看| 欧美精品色一区二区三区| 日本电影亚洲天堂一区| 北条麻妃一区二区三区| 99在线精品视频| eeuss鲁片一区二区三区在线看| 丁香网亚洲国际| 国产aⅴ精品一区二区三区色成熟| 国产精品99久久久久久久女警 | 欧美精品亚洲二区| 6080yy午夜一二三区久久| 制服丝袜亚洲色图| 日韩欧美国产不卡| 久久久久久一二三区| 26uuu精品一区二区在线观看| 国产丝袜欧美中文另类| 国产精品久久久久久久久果冻传媒 | 99久久精品99国产精品| www.视频一区| 色综合天天综合网天天狠天天| 91福利视频久久久久| 欧美日韩一区二区三区视频| 日韩一区二区三区三四区视频在线观看| 欧美日韩国产影片| 精品久久久久久综合日本欧美| 久久精品亚洲精品国产欧美kt∨| 国产精品美女久久久久av爽李琼 | 成人白浆超碰人人人人| 99在线精品一区二区三区| 在线观看成人小视频| 欧美精品tushy高清| 欧美日韩视频在线一区二区| 日韩一卡二卡三卡四卡| 国产欧美日韩卡一| 一区二区三区久久| 美洲天堂一区二卡三卡四卡视频 | 色素色在线综合| 欧美精品一卡两卡| 久久久99精品免费观看不卡| 亚洲综合自拍偷拍| 精品亚洲免费视频| 色综合久久中文字幕| 日韩欧美国产麻豆| 亚洲视频在线观看三级| 免费成人美女在线观看.| 北岛玲一区二区三区四区| 日韩一区二区电影| 一区二区日韩av| 国产一区二区在线影院| 欧美中文字幕一区二区三区| 26uuu精品一区二区| 亚洲香蕉伊在人在线观| 国产99久久精品| 日韩一区二区三区电影在线观看| 国产精品视频第一区| 久久精品国产一区二区三区免费看 | 成人av网站在线观看免费| 欧美高清精品3d| 中文字幕一区二区三区av| 久久精品国产在热久久| 欧美亚洲国产一区二区三区va| 国产亚洲精品aa| 免费成人av在线| 在线观看欧美黄色| 成人欧美一区二区三区在线播放| 国内成人精品2018免费看| 欧美精品第1页| 一个色综合av| 91在线视频播放地址| 日本一区二区三级电影在线观看| 日韩中文欧美在线| 欧美日韩一级视频| 一级精品视频在线观看宜春院 | 成人精品亚洲人成在线| 久久综合久久久久88| 日本va欧美va瓶| 日韩一级二级三级精品视频| 午夜久久久久久| 欧美三级一区二区| 樱花影视一区二区| 色狠狠一区二区三区香蕉| 亚洲欧洲av一区二区三区久久| 高清不卡一区二区| 国产偷国产偷精品高清尤物| 国产一区91精品张津瑜| 久久久精品蜜桃| 成人性生交大片免费看在线播放 | 天天av天天翘天天综合网| 欧美亚洲国产一区二区三区| 亚洲成人777| 69久久99精品久久久久婷婷|