添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Hey...
I am staritng winsock and creating a udp socket the usual way and anythig is finde (sendto works fine, too)...
But when trying to recvfrom(), I get the WSAEINVAL (10022) error and don´t know why...
I checked my parameters and they are passed correctly...
1
2
3
4
5
6
7
8
9
10
11
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)
m_InSock is the created socket,
fromlen should work, too,
c, too,
and addr is passed ( it is alive and not destroyed due to some block/-scope stuff...
So I am wondering, because the WSAEINVAL can also mean, that You need to bind a socket...
But that would be lame on the client -.-'...
Any suggestions/clues/etc?... I read on the remarks section again and found out, that a call to sendto binds the socket implicitly...
So i have to call bind before recvfrom always to ensure the linkage between the
W_Young wrote:
stack and the program
.
I guess, I will bind the socket to 0, to ensure a random port...