服务器
**************************************************************************************************************
#include
#include
#include
#include
#include
#include
#include
#define PORT 8888
#define IP "192.168.31.162"
#define ERR_MSG(msg) do{\
fprintf(stderr,"__%d__\n",__LINE__);\
perror("msg");\
}while(0)
int main(int argc, const char *argv[])
{
//1、创建套接字
int sfd = socket(AF_INET,SOCK_DGRAM,0);
if(sfd<0)
{
ERR_MSG("socket");
return -1;
}
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_port = htons(PORT);//端口号(主机端口号转为网络字节序)<