[En-Nut-Discussion] Client TCP probem

Julien CHAUSSEC Julien.Chaussec at ifremer.fr
Thu Aug 11 09:19:50 CEST 2005


Hello everybody,
Does anyone have a simple client Tcp program to mine doesn't work at 
all, and i really don't know why. Here is the main part of my client tcp 
file. Thanks for all.


void main (void)
{
long int i;


err_console = init_console();
if(err_console == 0)
	{
	dectection_configuration();
	}
init_controlleur_ethernet();
char tab [50];
int rt;

u_short error;		
#define remote_port		5010
u_long timeout	= 5000; 	/* time in milliseconde */
u_long timesend	;
u_long timercv	;	

	TCPSOCKET *sock = NutTcpCreateSocket();
	
	if (sock==0)
		{
		printf("problem create de socket \n\r");
		}
	printf("create socket OK\n\r");
	
	NutTcpSetSockOpt(sock, SO_SNDTIMEO,&timeout,4);
	NutTcpSetSockOpt(sock, SO_RCVTIMEO,&timeout,4);
	
	NutTcpGetSockOpt(sock, SO_SNDTIMEO,&timesend,4);
	NutTcpGetSockOpt(sock, SO_RCVTIMEO,&timercv,4);
	printf("time out send:%d \n\r",timesend);
	printf("time out receive:%d \n\r",timercv);
	
	if(NutTcpConnect( sock,inet_addr("134.246.147.85"), remote_port)==0)	
		{
		int a = 0;	
		for (a=0;a<11;a++)
			{
			sprintf(tab,"bonjour \n\r");
			printf(">>> connexion socket ok\n\r");
		
	
			if(NutTcpSend(sock, tab,sizeof(tab) )>0)
				{
				printf("envoi du mot:%s\n\r", tab);
				}	
				
			printf("socket state: %u\n\r",sock->so_state);
			}	
		}
	else
		{
		error = NutTcpError(sock);
		printf("error number %d\n\r", error);
		printf("<<< socket problem connexion \n\r");
		printf("socket state %u\n\r",sock->so_state);
		}
	for(i=0;i<99999;i++);
	for(i=0;i<99999;i++);
	for(i=0;i<99999;i++);
	for(i=0;i<99999;i++);
	
	rt = NutTcpCloseSocket(sock);
	printf("socket closed:%d\n\r",rt);
	
	
}


Julien.Chaussec at ifremer.fr




More information about the En-Nut-Discussion mailing list