Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

recvfrom error - what's this?

0 views
Skip to first unread message

Mechi Fendel

unread,
Oct 17, 2006, 5:20:49 AM10/17/06
to
Hi!
Here's some code that used to work well. Now the recvfrom command returns
an error that WSAGetLastError reports is 1421. This is not in the WSA range
of errors - what does this mean?


Thanks for any help,
Mechi

fds has only one socket in its list - fd.

rc = select(0, &fds, NULL, NULL, &timeout); // rc =1
Delay(500);
...
dummylen = 0;
memset(buffer, 0, 2048);
rc = recvfrom(fd, (char *)buffer, 2048, 0, (struct sockaddr
*)&peer_addr, &dummylen);
if(rc < 0)
{
int err;
/*
* Check for error type - we may get a "reset by peer" error
which
* indicates a packet we sent was dropped - which is OK
*/

err = WSAGetLastError();
}

MON205

unread,
Oct 17, 2006, 7:19:02 AM10/17/06
to
ERROR_CONTROL_ID_NOT_FOUND declared in the winerror.h

I don't know exactly what is the problem, but any way you should initialize
the socket size.
int dummylen = sizeof( SOCKADDR_IN );

/////////////////////////////////////
"Mechi Fendel" wrote:

> Hi!
> Here's some code that used to work well. Now the recvfrom command returns
> an error that WSAGetLastError reports is 1421. This is not in the WSA range
> of errors - what does this mean?
>
>
> Thanks for any help,
> Mechi
>
> fds has only one socket in its list - fd.
>
> rc = select(0, &fds, NULL, NULL, &timeout); // rc =1
> Delay(500);

> ....

Mechi Fendel

unread,
Oct 17, 2006, 7:35:25 AM10/17/06
to
I checked the err in the wrong place. The real error is 10054 -
WSAECONNRESET
I tried to use WSARecv (simple, non-blocking socket, no overlap) instead of
recvfrom and the CPU use went from 40% to 93%. Why is this?
I think the WSARecv works better - the first 2 tries receives WSAECONNRESET
erro, but succeeds on the 3rd time. For some reason, though, the connection
closes down.
Mechi


"Mechi Fendel" <mec...@ozvision.com> wrote in message
news:e5TEX2c8...@TK2MSFTNGP05.phx.gbl...

Arkady Frenkel

unread,
Oct 17, 2006, 10:05:38 AM10/17/06
to
Do you have other side and connection established ( check it with netstat )
for WSARecv ?
Arkady

"Mechi Fendel" <mec...@ozvision.com> wrote in message

news:OkxRkBe8...@TK2MSFTNGP02.phx.gbl...

Alexander Nickolov

unread,
Oct 17, 2006, 5:18:06 PM10/17/06
to
So is this a TCP or UDP socket? WSAECONNRESET typically
happens on TCP sockets only, since there's no connection with
UDP. However, recvfrom is typically used with UDP sockets
only, since you can receive datagrams from many hosts. Your
comments are very confusing too...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Mechi Fendel" <mec...@ozvision.com> wrote in message

news:OkxRkBe8...@TK2MSFTNGP02.phx.gbl...

0 new messages