Do I have to bind an UDP socket in my client program, to receive data? (I always get WASEINVAL)...
- by Incubbus
Hey There,
I have the following problem:
I am starting WSA, then I am creating a UDP socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP) and try to recvfrom on this socket, but it always returns -1 and I get WSAEINVAL (10022)... I don´t know why?...
When I bind the port, that does not happen...
But it is very lame to bind the clients socket... (As far as I remember, i never had this problem before:/ )...
Anyone knows why this happens?...
(I am sending data to my server, which anwsers[ or at least, tries to^^])...
Inc::STATS CConnection::_RecvData(sockaddr* addr, std::string &strData)
{
int ret, len, fromlen; //return code / length of the data / sizeof(sockaddr)
char *buffer; //will hold the data
char c;
//recv length of the message
fromlen = sizeof(sockaddr);
ret = recvfrom(m_InSock, &c, 1, 0, addr, &fromlen);
if(ret != 1)
{
#ifdef __MYDEBUG__
std::stringstream ss;
ss << WSAGetLastError();
MessageBox(NULL, ss.str().c_str(), "", MB_ICONERROR | MB_OK);
#endif
return Inc::ERECV;
}...