AW: [En-Nut-Discussion] Connection reset when trying to connect

Oliver Schulz olischulz at web.de
Sun Oct 12 14:47:37 CEST 2003


Hi Harald (Kipp),

when I tried to follow up the code of the TCP Stack, I noticed a possible
bug, or perhaps I just didn't understand...

If NutTcpConnect if invoked, the Nut/NET sends a SYN packet to the peer, the
socket goes into TCPS_SYN_SENT state and the application is blocked and
waits for so_ac_tq event.

The next received packet is handled by NutTcpStateSynSent. If TH_SYN is set
without TH_ACK, the stack changes the state to TCPS_SYN_RECEIVED and sends a
SYN & ACK packet to the peer. This is ok, because simultaneous initiation of
the connection can occur according to the rfc.

But then, the next packet is handled by NutTcpStateSynReceived, if an RST is
received the state changes to TCPS_LISTEN, which converts the socket to a
listen-socket as you would have called NutTcpAccept ?!?

If not an RST is received an the stack thinks the packet ok, it changes the
state to TCPS_ESTABLISHED, but this state change posts the so_pc_tq event
and not the so_ac_tq. Thus the first called NutTcpConnect is never
unblocked.

What's your point of view about this?

Regards,
Oliver.



-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de]Im Auftrag von Martin Kresse
Gesendet: Sonntag, 12. Oktober 2003 06:30
An: en-nut-discussion at egnite.de
Betreff: [En-Nut-Discussion] Connection reset when trying to connect


Hi there,

I want my ethernut to establish a tcp connection to a server (my PC),
that might not always be available. If the serving application is
already running when I try to connect via NutTcpConnect(), the
connection will be established and everything works just fine.
However, if I start the service after the ethernut is already trying to
connect to it (in a loop), something strange happens on the server side
(which is actually a Java application). The blocking accept() call
returns, I get a Socket object that represents the connection to my
ethernut and it looks like the connection is established. But
NutTcpConnect() is still blocked (it will eventually return with -1 and
tcp error set to ECONNREFUSED) and when I try to read or write to the
socket (on the serverside), I get a socket exception "Connection reset".
I know this sounds like a Java problem and this is not a Java forum, but
I am pretty sure that Java's underlying implementation is correct (as
are my 5 lines of code), and that the problem lies somwhere within Nut/Net.
Does anyone have any idea what might be the problem and how to avoid a
real ugly workaround on the server side?

Sincerely,
  Martin Kresse

_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list