tcp socket detection problems

Started by newdep, March 02, 2004, 12:05:29 PM

Previous topic - Next topic

newdep

Hello Lutz,



Im trying some basic (net-send) and control over (net-sessions) "open ports"

and Im running into a problem.



(1) It seems that newlisp does detect "remote" tcp hangups too late..

(2) (net-sessions) isnot updated when remote peer hangs up.



Here is exmaple #1



---- test ----

(set 'server (net-listen 1234))

(println (net-sessions))

(set 'conn (net-accept server))

(println (net-sessions))

----



> (load "test")

(4)

*** I now connect with a remote telnet to port 1234 ***

(5 4)

true

> (net-send 5 "hello")

5

*** here I disconnect the remote CLIENT ***

*** Still newlisp seems an open socket ***

> (net-send 5 "hello")

5

> (net-send 5 "hello")

5

> (net-send 5 "hello")

Broken pipe  

$shell>



*** see the broken pipe above, its always after 2x sending towards

*** a remote peer which is already gone



*** problem number #2 is that (net-sessions) is not updated when

*** a remote peer hangs up the connection.

*** im not sure if there is a difference in behaviour running in console

*** mode or running from file execution.



Hope you have an idea on the above...



Regards,

Norman.
-- (define? (Cornflakes))

newdep

#1
Hello Lutz,



* Linux 7.7.5



I had a look in your code and if seems the socket is only then removed

from the (net-sessions) when a 'write towards the socket fails, it has

some disadvantages doing this but never the less i can work around that i

think.



Still, currently a  "Broken Pipe" and a hard exit is what i get

when sending data to an non existing socket/port.



Hope you can fix the "broken pipe" issue



Regards,

Norman.
-- (define? (Cornflakes))

Lutz

#2
I have fixed this for LINUX and it will be in 7.5.6 this week. There is no way to trap the dropped line on the first send, but the second send now will return 'nil' and (net-error) will give a: "9 Socket send failed" error and the offending socket will be removed from the (net-sessions) list.



On Win32 no fix is necessary as the socket implementation seems to handle the sig pipe exception already.



Also, it seems to me that on 'net-receive-udp' it is never necessary to set broadcast mode on the socket, at least on my Linux Mandrake 9.2 machine, but it is included in the code and can be set for both send/receive-udp. I also implemented the Ctrl-C handler, in a simpler fashion on Win32 and more comfortable on Linux/BSD with a continue/exit/reset menu.



Tomorrow I will test 7.5.6 a litle an then release it as a developers version before the week is over.



I am glad you are catching some of the more subtle errors in the Tcp/Ip implementation and hope we can work out things before 8.0.



Lutz

newdep

#3
Hello Lutz,



You are a doing a nice job improving newlisp :-) thank you for that.



Yes you are right on the (net-receive-udp) issue, for UDP Broadcast

there is no need to have it enabled on the receive socket there the

broadcast address/subnet will make sure the data is delivered. But i

can remember that on some OS's there is a need to enable is still on

the socket, but dont know for sure now anymore...



Still what could be confusing is the implementation of

(net-listen PORT ADDRESS ) versus (net-send ADDRESS PORT)  ;-)



I very currious on the next release...



Regards, Norman.
-- (define? (Cornflakes))