计算机网络:socket

UDP变成 C/S架构

#include<stdlib.h>
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>

int main(){
	
	// 使用socket函数创建套接字
	// 创建一个用于udp网络编程的套接字
	int sockfd = socket(AF_INET, SOCK_DGRAM,0);
	printf("socket文件描述符%d\n",ret);
	
	if(sockfd == -1){
		perror("fail to socket");
		exit(1);
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_37564426/article/details/114186457
今日推荐