CWinThread exits when calling recvfrom
-
Hi, I'm using a CWinThread to send and recieve ICMP packets (pings). but while recieving the echo replys the thread exits. Thats the code I'm calling:
char* echoReply = new char[50]; int nRet; int nAddrLen = sizeof(struct sockaddr_in); sockaddr_in lpsaFrom; lpsaFrom.sin_family = AF_INET; lpsaFrom.sin_port = 0; lpsaFrom.sin_addr.s_addr = inet_addr("192.168.6.100"); // Recieve the echo reply nRet = recvfrom(s, echoReply, sizeof(echoReply), 0, (sockaddr*) &lpsaFrom, &nAddrLen);
when calling recvfrom() the thread breaks down. even the debugger does not stop at any breakpoints i have set after the recvfrom call. has anybody an idea? PS: recv also doesn't work and bind works fine... -
Hi, I'm using a CWinThread to send and recieve ICMP packets (pings). but while recieving the echo replys the thread exits. Thats the code I'm calling:
char* echoReply = new char[50]; int nRet; int nAddrLen = sizeof(struct sockaddr_in); sockaddr_in lpsaFrom; lpsaFrom.sin_family = AF_INET; lpsaFrom.sin_port = 0; lpsaFrom.sin_addr.s_addr = inet_addr("192.168.6.100"); // Recieve the echo reply nRet = recvfrom(s, echoReply, sizeof(echoReply), 0, (sockaddr*) &lpsaFrom, &nAddrLen);
when calling recvfrom() the thread breaks down. even the debugger does not stop at any breakpoints i have set after the recvfrom call. has anybody an idea? PS: recv also doesn't work and bind works fine...This may not fix the problem but...
sizeof(echoReply)
will return 4 (the size of the pointer), not 50. You need to specify 50 instead ofsizeof(echoReply)
.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"