本文介绍了UDP绑定错误10048 WSAEADDRINUSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我们遇到了一个奇怪的问题。


在我们的WEC7系统(imx6处理器)上有一个类似的线程这个:


  while(true){

    ServerSocket = socket(AF_INET,SOCK_DGRAM,0);

    address.sin_family = AF_INET;

    address.sin_addr.s_addr = htonl(INADDR_ANY);

    address.sin_port = htons(SETIP_PORT);


    bind(ServerSocket,(struct sockaddr *)& address,len); 


    setsockopt(ServerSocket,SOL_SOCKET,SO_BROADCAST,(char *)& allowed,sizeof(允许));

     recvfrom(ServerSocket,(char *)buffer,sizeof( buffer),0,(struct sockaddr *)& address_from,& len);


    sendto(ServerSocket,antwort,strlen(antwort),0,(sockaddr *)& sa,sizeof(sa));


    closesocket(ServerSocket);


}


这一直适用于我们的compony网络。从下午5点开始(当大多数人回家时) 在绑定我们得到约5分钟后错误10048 WSAEADDRINUSE。在我们ping设备之前,这种错误情况一直存在。然后它可以用于另一个
几分钟。


我们在WinCE5系统(XScale处理器)上运行相同的源代码多年来在同一环境中没有问题。


任何想法?






解决方案

hello,

we have encountered a strange problem.

On our WEC7 systems (imx6 processor) there is a thread like this:

 while (true) {
    ServerSocket = socket(AF_INET,SOCK_DGRAM,0);
    address.sin_family = AF_INET;
    address.sin_addr.s_addr = htonl(INADDR_ANY);
    address.sin_port = htons(SETIP_PORT);

    bind(ServerSocket,(struct sockaddr*)&address, len); 

    setsockopt(ServerSocket,SOL_SOCKET,SO_BROADCAST,(char*)&allowed,sizeof(allowed));
    recvfrom(ServerSocket,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&address_from,&len);

    sendto(ServerSocket,antwort,strlen(antwort),0,(sockaddr*)&sa,sizeof(sa));

    closesocket(ServerSocket);

}

This works well in our compony's network all the day. Starting at 5 p.m. (when most people go home)  at bind we get about after 5 minutes an error 10048 WSAEADDRINUSE. This error situation stays until we ping the devices. Then it works ok for another few minutes.

We have the same source code running on our WinCE5 systems (XScale processor) for years without problems in the same environment.

Any ideas ?

解决方案


这篇关于UDP绑定错误10048 WSAEADDRINUSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 04:58