[En-Nut-Discussion] NutTcpConnect and NutTcpCloseSocket problem
Ole Reinhardt
ole.reinhardt at embedded-it.de
Thu Aug 9 01:15:08 CEST 2012
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
More information about the En-Nut-Discussion
mailing list