|
我在用udp协议的接收函数recvfrom()时,出现了问题:
int RawSock::receive(void *buf,int buflen,struct sockaddr *from,int *len)
{
while(1)
{
int length = recvfrom(sock,buf,buflen,0,from,len); //line 133
}
}
我编译时,出现:
[root@localhost Ping]# g++ ping.c -o ping
ping.c: In member function `int RawSock::receive(void*, int, sockaddr*, int*)'
:
ping.c:133: invalid conversion from `int*' to `socklen_t*'
然后,我把133行该为:
int length = recvfrom(sock,buf,buflen,0,from,(socklen_t *)(sizeof(struc
t sockaddr)));
这时编译没有问题了,但是程序运行时候,出现接收Receive()错误!
请高手帮忙,我是错在那里拉? |
|