我先通过recvfrom(MyServer, (char *)&recvbuf, sizeof(recvbuf), 0, (sockaddr *)&sender, &sendlen);得到发送端的地址结构sender,然后想把数据原样返回给发送端
sendto(MyServer, (const char*)&recvbuf, sizeof(recvbuf), 0, (const sockaddr*)&sender, sizeof(sender));
请问有错吗?
为什么发不出去啊?

解决方案 »

  1.   

    The sendto function is used to write outgoing data on a socket. For message-oriented sockets, care must be taken not to exceed the maximum packet size of the underlying subnets, which can be obtained by using getsockopt to retrieve the value of socket option SO_MAX_MSG_SIZE. If the data is too long to pass atomically through the underlying protocol, the error WSAEMSGSIZE is returned and no data is transmitted