急切希望得到帮助

小弟最近编了一个用udp传输文件的程序,在linux下编译通过并能正常运行,但在qnx下编译通过后,client端的recvfrom函数出现问题,

sockfd=socket(AF_INET,SOCK_DGRAM,0)

char buf_small[30];//用来接受文件大小数据的变量

temp_size=recvfrom(sockfd,buf_small,sizeof(buf_small),0,(struct sockaddr *)&from,&fromlen);

if(temp_size<0)
{
fprintf(stderr,“Receiving tot_size of file error:%s\n”,strerror(errno));
close(sockfd);
exit(-1);
}
结果temp_size返回的是-1,errno为240,
输出结果为Receiving tot_size of file error:message too long
我初始认为是缓冲区不够大,但是加大了缓冲区也没有用。结果依然是这样,然后看了errno.h中errno变量为240对应的是
#define EMSGSIZE 240 /* Inappropriate message buffer length */
请高手指点我应该怎么办,这个程序我在红旗linux下编译通过后不会出现这种错误的。

这段程序好像没什么问题,可能是创建socket有问题吧

自己参考一下:
int CBlockSocket::SendDatagram(const char* pch, const int nSize, LPCSOCKADDR psa, int nSeconds)
{
ASSERT(m_hSocket != NULL);
ASSERT(nSize>0);
fd_set fd ;
FD_ZERO(&fd);
FD_SET(m_hSocket,&fd);
TIMEVAL tv = {nSeconds, 0};
if (select(m_hSocket+1, NULL, &fd, NULL, &tv) == 0)
{
throw new CBlockSocketException(“Send timeout”);
}

int nBytesSent = sendto(m_hSocket, pch, nSize, 0, psa, sizeof(SOCKADDR));
if (nBytesSent == SOCKET_ERROR)
{
throw new CBlockSocketException(“SendDatagram”);
}
return nBytesSent;
}

int CBlockSocket::ReceiveDatagram(char *pch, const int nSize, LPSOCKADDR psa, int nSeconds)
{
ASSERT(m_hSocket != NULL);
ASSERT(nSize>0);
fd_set fd ;
FD_ZERO(&fd);
FD_SET(m_hSocket,&fd);
TIMEVAL tv = {nSeconds, 0};
if (select(m_hSocket+1, &fd, NULL, NULL, &tv) == 0)
{
throw new CBlockSocketException(“Receive timeout”);
}
int nFromSize = sizeof(SOCKADDR);
int nBytesReceived = recvfrom(m_hSocket, pch, nSize, 0, psa, &nFromSize);
if (nBytesReceived == SOCKET_ERROR)
{
throw new CBlockSocketException(“ReceiveDatagram”);
}
return nBytesReceived;
}