[En-Nut-Discussion] NutTcpConnect and NutTcpCloseSocket problem
CAMBON, Olivier
Olivier.CAMBON at astrium.eads.net
Fri Aug 10 11:27:12 CEST 2012
Hi,
i found the problem !
the function "test_connection" is called in a thread which priority is 23.
I tried with a priority higher or equal to 32 (priority of the thread "tcpsm") and it works fine.
Do you have any why ?
Regards,
Olivier.
-----Original Message-----
From: CAMBON, Olivier
Sent: Thursday, August 09, 2012 10:33 AM
To: 'Ethernut User Chat (English)'
Subject: RE: [En-Nut-Discussion] NutTcpConnect and NutTcpCloseSocket problem
Hi,
thanks for all your answer.
I will check the stack soon.
Could you explain how to activate DEBUG ?
I use Nut/OS 4.10.1
Here is my code :
uint8_t test connection(char* ip, uint16_t port)
{
uint32_t rip = 0;
u_long sock_opt = 0;
TCPSOCKET *sock = NULL;
/* Check the entries */
if(ip == NULL) { return 1; }
/* Get the inet for the IP */
rip = inet_addr(ip);
/* Check the inet we got */
if(rip == 0) { return 2; }
/* Create socket for the connection to the IP */
sock = NutTcpCreateSocket();
if(sock == NULL) { return 3; }
/* Set send timeout */
sock_opt = 10000;
NutTcpSetSockOpt(sock, SO_SNDTIMEO, &sock_opt, sizeof(sock_opt));
/* Set receive timeout */
sock_opt = 30000;
NutTcpSetSockOpt(sock, SO_RCVTIMEO, &sock_opt, sizeof(sock_opt));
/* Connect the server of the IP */
if(NutTcpConnect(sock, rip, port) != 0) { NutTcpCloseSocket(sock); return 4; }
/* Connection OK */
NutTcpCloseSocket(sock);
return 0;
}
Best regards,
Olivier.
-----Original Message-----
From: en-nut-discussion-bounces at egnite.de [mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of DreamCat
Sent: Thursday, August 09, 2012 6:16 AM
To: Ethernut User Chat (English)
Subject: Re: [En-Nut-Discussion] NutTcpConnect and NutTcpCloseSocket problem
Hi,
Enable the DEBUG function with it.
You have to use "CloseSocket", otherwise this will cause your ethernut
board still work on that links, even it is dead.
2012/8/9 Ole Reinhardt <ole.reinhardt at embedded-it.de>
> Hi Oliver,
>
>
> > But, I have a problem with NutTcpConnect.
> > I use this function to test if a computer of my network is started and
> > its program is ready to listen.
> > The problem is when the computer is offline, in the following code,
> > NutTcpCloseSocket does a reset of the board :
> >
> > if(NutTcpConnect(sock, rip, port) != 0) { NutTcpCloseSocket(sock);
> > return -1; }
>
> I would expect the problem any where else. Do you perhaps try to later
> access the socket variable after having closed the socket before?
>
> And are you sure that "sock" is valid?
>
> Do you have implemented it this way?
>
> TCPSOCKET *sock;
>
> if ((sock = NutTcpCreateSocket()) != 0) {
> if(NutTcpConnect(sock, rip, port) != 0) {
> NutTcpCloseSocket(sock);
> return -1;
> } else {
> /* do something here */
> NutTcpCloseSocket(sock);
> return 0;
> }
> } else {
> printf("Out of memory?\n);
> }
>
> Normaly this should be working fine so I expect a buffer overflow or
> access of an invalid pointer at some place in your user code.
>
> Perhaps you could post a lager piece of code so we could see the
> context.
>
> Another problem might be the stack. Have you implemented this as a
> thread? Do you use lots of local variables or large local arrays?
>
> A stack overflow could also result in a reboot.
>
> Bye,
>
> Ole
>
> --
>
> Thermotemp GmbH, Embedded-IT
>
> Embedded Hard-/ Software and Open Source Development,
> Integration and Consulting
>
> http://www.embedded-it.de
>
> Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen -
> tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97
>
> Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
> Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
> Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
> Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
--
【花生】
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Ce courriel (incluant ses eventuelles pieces jointes) peut contenir des informations confidentielles et/ou protegees ou dont la diffusion est restreinte. Si vous avez recu ce courriel par erreur, vous ne devez ni le copier, ni l'utiliser, ni en divulguer le contenu a quiconque. Merci d'en avertir immediatement l'expediteur et d'effacer ce courriel de votre systeme. Astrium decline toute responsabilite en cas de corruption par virus, d'alteration ou de falsification de ce courriel lors de sa transmission par voie electronique.
This email (including any attachments) may contain confidential and/or privileged information or information otherwise protected from disclosure. If you are not the intended recipient, please notify the sender immediately, do not copy this message or any attachments and do not use it for any purpose or disclose its content to any person, but delete this message and any attachments from your system. Astrium disclaims any and all liability if this email transmission was virus corrupted, altered or falsified.
---------------------------------------------------------------------
Astrium SAS (393 341 516 RCS Nanterre) - Capital: 16.587.728 EUR - Siege social: 12 rue Pasteur, 92150 Suresnes, France
More information about the En-Nut-Discussion
mailing list