UDP C代码

UDP C代码

/*加载库文件*/

#pragma comment( lib, "ws2_32.lib" ) /*加载头文件*/

#include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> #include <stdlib.h>

/*定义多播常量*/

#define MCASTADDR "224.3.5.8" #define MCASTPORT 25000 #define BUFSIZE 1024 #define MCOUNT 10

/*定义广播常量*/

#define BCASTPORT 5050 #define BCOUNT 10

/*定义广播全局变量*/

SOCKET socketBro; SOCKET socketRec; struct sockaddr_in addrBro; struct sockaddr_in addrRec;

BOOL broadSendFlag; BOOL broadFlag;

DWORD bCount; DWORD bcastAddr; short bPort;

/*定义多播全局变量*/

SOCKET socketMul; SOCKET sockJoin; struct sockaddr_in addrLocal; struct sockaddr_in addrMul;

BOOL multiSendFlag; BOOL bLoopBack; BOOL multiFlag;

DWORD dwInterface; DWORD dwMulticastGroup; DWORD mCount; short mPort;

UDP C代码相关文档

最新文档

返回顶部