udp客户端
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#define CLIENT_IP "192.168.8.101" //客户端 IP
#define SERVER_IP "192.168.8.101" //服务器 IP
#define SERVER_PORT 8888 //服务器端口号
#define CLIENT_PORT 6666 //客户端端口号
#define MAX 128
#define ERROR(msg) do{
\
fprintf(stderr, "__%d__", __LINE__);\
perror(msg);\
}while(0)
int main(int argc, char *argv[])
{
int cfd,sfd;
struct sockaddr_in client_addr,server_addr;
socklen_t server_addr_size, client_addr_size;
//1.创建数据报式套接字
cfd = socket(AF_INET, SOCK_DGRAM, 0);
if (cfd == -1)
{
ERROR("socket");
return -