[En-Nut-Discussion] NutTcpSend / NutTcpReceive

Joachim Skale joachim.skale at tele2.at
Wed Nov 23 14:12:16 CET 2005


hi all,

i had some troubles with NutTcpSend / NutTcpReceive.

First my appl. should connect to a TCP Server.
After the first connect, the Server Version should be read out.
at a given Event the board should send another TCP Call to the server.
but a that time the server didn't get anything.

the two commands are described below:
has anyone some suggestions whats wrong ?


Thanks in advice


Joachim


codesnip:
...
u_char rec_version(TCPSOCKET *sock)
{
	uint8 answer[256] = { 0 };
	u_char cmd[256];
	size_t rc;
	int bite;
	
	packet_reqver *panswer = (packet_reqver *)&answer;
	panswer->dataid = PACKET_ID_GETVER;
	panswer->length = 0;

	printf("First Getting Server Version...");
	u_long len;
	len = (6+panswer->length);
	
	for (rc = 0; rc < len; rc += bite)
	{
		if ((bite = NutTcpSend(sock, answer + rc, len - rc)) <= 0)
			break;
	}
	memset(cmd, 0, sizeof cmd);
	if (NutTcpReceive(sock, cmd, sizeof cmd)>0)
	{
		ProcessRequests(cmd);		
		return 0;
	}
	return 1;
}
....snip...

void rec_snr(TCPSOCKET *sock, const u_long s)
{
	uint8 answer[256] = { 0 };
	u_char cmd[256];
	size_t rc;
	int bite;
	
	packet_querysnr *panswer = (packet_querysnr *)&answer;
	panswer->dataid = PACKET_ID_QUERYSNR;
	panswer->snr = s;
	panswer->length = 4;

	printf("Query CSC Serial ...");
	u_long len;
	len = (6+panswer->length);
	
	for (rc = 0; rc < len; rc += bite)
	{
		if ((bite = NutTcpSend(sock, answer + rc, len - rc)) <= 0)
			break;
	}
	memset(cmd, 0, sizeof cmd);
	if (NutTcpReceive(sock, cmd, sizeof cmd)>0)
	{
		printf("\nGot answer.\n");
		ProcessRequests(cmd);
	}
}





More information about the En-Nut-Discussion mailing list