我想通过使用下面的代码发送UDP,但我得到奇怪的结果。当totalLength变量设置为30 sendto函数实际上返回2292556,它应该不会再重返至少围绕盘的30标记的东西C windows sendto()
if((sendto(newSocket, sendBuf, totalLength, 0, (SOCKADDR *)&sendAddr, sizeof(sendAddr)) == bytesSent) < 0)
{
printf("Send error! - %d\n", WSAGetLastError());
}
但是说什么?在使用sendto之前,我已经检查了totalLength变量,它会愉快地返回一个我同意的值,然后sendto返回一个巨大的值。总长度从不大于实际缓冲区大小。
WSAGetLastError刚刚返回0.
谢谢。
啊是的,当然我不能相信我没有看到这一点。我已经为此感到沮丧了将近一个小时v.v – Alistair 2009-11-23 21:05:04
Blame =,==和行太长了:) – schnaader 2009-11-23 21:06:45