实现UDP协议传输的C语言程序。如被采纳,可追加悬赏,盼高手指教,不胜感激!!!
2011-11-26
展开全部
原型:
int WINAPI icePub_UdpSendAndReceive(char *sendBuffer,int bufferLen,char *strIP,int port,char *receiveBuffer,int timeoutSeconds,int retryCounts)
输入:sendBuffer 发送的数据
bufferLen sendBuffer的长度
strIP 服务端地址
port 端口
timeoutSeconds 超时时间,秒
retryCounts 接收失败重发次数
输出:receiveBuffer 接收的数据
返回码:接收数据的长度
char buff[1024],buff2[1024*10];
int receiveLen;
strcpy(buff,"tag:01\r\ncommand:reboot\r\ndata:none\r\n");
typedef int (WINAPI ICEPUB_UDPSENDANDRECEIVE)(char *sendBuffer,int bufferLen,char *strIP,int port,char *receiveBuffer,int timeoutSeconds,int retryCounts);
ICEPUB_UDPSENDANDRECEIVE *icePub_UdpSendAndReceive = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
icePub_UdpSendAndReceive=(ICEPUB_UDPSENDANDRECEIVE *)GetProcAddress(hDLLDrv,"icePub_UdpSendAndReceive");
if(icePub_UdpSendAndReceive)
receiveLen=icePub_UdpSendAndReceive(buff,strlen(buff),"192.168.1.111",6000,buff2,15,1);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
AfxMessageBox(buff2);
int WINAPI icePub_UdpSendAndReceive(char *sendBuffer,int bufferLen,char *strIP,int port,char *receiveBuffer,int timeoutSeconds,int retryCounts)
输入:sendBuffer 发送的数据
bufferLen sendBuffer的长度
strIP 服务端地址
port 端口
timeoutSeconds 超时时间,秒
retryCounts 接收失败重发次数
输出:receiveBuffer 接收的数据
返回码:接收数据的长度
char buff[1024],buff2[1024*10];
int receiveLen;
strcpy(buff,"tag:01\r\ncommand:reboot\r\ndata:none\r\n");
typedef int (WINAPI ICEPUB_UDPSENDANDRECEIVE)(char *sendBuffer,int bufferLen,char *strIP,int port,char *receiveBuffer,int timeoutSeconds,int retryCounts);
ICEPUB_UDPSENDANDRECEIVE *icePub_UdpSendAndReceive = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
icePub_UdpSendAndReceive=(ICEPUB_UDPSENDANDRECEIVE *)GetProcAddress(hDLLDrv,"icePub_UdpSendAndReceive");
if(icePub_UdpSendAndReceive)
receiveLen=icePub_UdpSendAndReceive(buff,strlen(buff),"192.168.1.111",6000,buff2,15,1);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
AfxMessageBox(buff2);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询