[REBOL] Re: Maximum number of listening ports
From: lmeyer:bltech:za at: 22-Feb-2010 12:02
Hi Graham
Yes, I believe you are on the right track.
I have downloaded a utility called Socketsniff. It proves that it keeps
every Socket open on the server even if the client closes the socket (telnet
being the client in this case).
As the server script copies the multicast stream to every connected socket,
the number of active sockets just grows and grows until the new socket
requests are declined. After a couple of minutes I had 100 open sockets
within only 2 active clients.
How do I build-in a check in the script below to see if the client's tcp
port is still active and if not, close that tcp socket?
REBOL [ Title: "4550"]
mon-address: read make url! join "dns://" (read dns://)
inputmulticast: open/direct/binary udp://:6550
set-modes inputmulticast [multicast-groups: copy compose/deep[[239.2.0.81
(mon-address)]] ]
listen: open/direct/binary/no-wait tcp://:4550
output-ports: copy []
forever [
port: wait [listen inputmulticast]
case [
port = listen [
; we got a new connection
; let's add it to the list of output ports
append output-ports first listen
]
'else [
; some data incoming
data: copy inputmulticast
foreach port output-ports [
insert port data
]
]
]
]
Thanks
Leon