[En-Nut-Discussion] TCP server
Harald Kipp
harald.kipp at egnite.de
Mon Jul 18 17:09:21 CEST 2011
Hi Valentin,
On 7/18/2011 1:41 PM, Valentin Dodov wrote:
> I'm trying to create and test simple TCP server.
You do know
http://www.ethernut.de/nutwiki/Basic_TCP_Server
http://www.ethernut.de/nutwiki/Basic_TCP_Client
right?
> My program starts one thread which listens for incoming connections on
> port 21 and one thread which connects to port 21.
>
> When second thread tries to creates socket there are 2 sockets and the
> first one is allays in SYNSENT state:
I'm confused. According to the first sentence, the first socket is a
server socket, which should never get into SYN_SENT.
Client sockets will get into SYN_SENT state, if there is no response
from the server. This state may last a quite long time until
NutTcpConnect() finally gives up and returns an error. I'd recommend to
further analyze this with
http://www.wireshark.org/
Also check
http://en.wikipedia.org/wiki/SYN_%28TCP%29#Connection_establishment
> This is my code:
> NutTcpAccept (sock, 21);
> puts ("Client connected\n");
> stream = _fdopen((int) sock, "r+w");
> fclose (stream);
> NutTcpCloseSocket (sock);
> printf ("Client disonnected\n");
Isn't there some input missing. The server socket will immediately
closing the socket as soon as a connection is established. Do you want
this? Isn't there an fgets or similar missing?
Regards,
Harald
More information about the En-Nut-Discussion
mailing list