qfedu-network-advanced-level/day2/n5.c

21 lines
349 B
C
Raw Permalink Normal View History

2023-09-05 20:54:17 +08:00
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
int main(int argc, char const *argv[])
{
// 创建socket
int socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (socket_fd < 0)
{
perror("socket");
return 1;
}
printf("socket 创建成功: %d\n", socket_fd);
close(socket_fd);
return 0;
}