AW: AW: AW: AW: [En-Nut-Discussion] net Errno 10057

Joachim Skale joachim.skale at tele2.at
Thu Dec 1 08:48:35 CET 2005


hi, 

i will try with etherreal.

here are the code parts.

u_char rec_version(TCPSOCKET *so)
{
	size_t rc;
	int bite = 0;
	static uint8 answer[20];
	static u_char cmd[50];

	while (so->so_state != TCPS_ESTABLISHED)
	{
		Connect_Server(so);
	}
	memset(answer, 0x00, sizeof answer);
	packet_reqver *panswer = (packet_reqver *)&answer;
	panswer->dataid = PACKET_ID_GETVER;
	panswer->length = 0;

	printf("First Getting Server Version...");
	u_long len;
//	for (len=0; len < (6+panswer->length); len++)
//		printf("%02X", answer[len]);

	len = (6+panswer->length);
	for (rc = 0; rc < len; rc += bite)
	{
		if ((bite = NutTcpSend(so, answer + rc, len - rc)) <= 0)
			break;
	}
	if (bite == 0)
	{
		printf("Timeout while Sending Data.\n");
		return 1;
	}
	else if (bite == -1)
	{
		printf("Error while Sending Data. (%d)\n", NutTcpError(so));
		return 1;
	}
	else
	{
		memset(cmd, 0, (sizeof (cmd)));
		len = sizeof (cmd);
		if ((bite = NutTcpReceive(so, cmd, len))<=0)
		{
			if (bite == 0)
				printf("Timeout while Receiving Data.\n");
			if (bite == -1)
				printf("Error while Receiving Data. (%d)\n", NutTcpError(so));
		}
		else
		{
			ProcessRequests(cmd);
			return 0;
		}
	}
	return 1;
}

and this function will be called from my Thread.

Joachim

-----Ursprungliche Nachricht-----
Von: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de]Im Auftrag von Harald Kipp
Gesendet: Mittwoch, 30. November 2005 18:41
An: Ethernut User Chat (English)
Betreff: Re: AW: AW: AW: [En-Nut-Discussion] net Errno 10057



>
>After sending over TCP i checked the state. Everything was fine.
>But after calling NutTcpReceive the socket state != TCPS_ESTABLISHED 
>without any changes from me.

OK. In that case I'd recommend to use Ethereal. I do
not believe that "no one did not do anything".
Someone, either the PC or the Ethernut closes the
connection and Ethereal will show the FIN segments.

Btw., can you post the part of the code that calls
NutTcpReceive, including the declaration of the
buffer variable (and optionally the malloc, if one
is used)?

Harald


_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion



More information about the En-Nut-Discussion mailing list