1. TCP服务器端流程
2. TCP客户端流程
3. TCP/IP服务器端与客户端框架
示例代码:
TCP服务器端:
/*************************************************************************
@Author: wanghao
@Created Time : Fri 25 May 2018 08:09:19 PM PDT
@File Name: server.c
@Description:
************************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#define N 36
#define MAXSIZE 24
void *thread_functio(void *client_fd);
int main(int argc, const char *argv[])
{
int socketfd;
int client_fd;
int addrlen;
u_short port;
pthread_t a_thread;