#include <stdio.h>
#include <winsock2.h>
#include <sys/types.h>
#include <stdlib.h>
int main() {
//使用socket函数创建套接字
//创建一个用于UDP网络编程的套接字
int sockfd;//创建来接收socket的返回值
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("Socket调用失败");
exit(1);//退出程序
}
printf("sockfd = %d\n", sockfd);
return 0;
}
结果