Re: IO::Socket Stop listening for new connections after initial connection



> One thing is that you really should use strict; use warnings; and check
> the success of your system calls. If you did that, I think the problem
> would have made itself more clear to you.

I'll be doing that from now on.

> Here is the root cause of the problem. You are closing $agent_sock, but
> then leaving it in the watch list for the IO::Select object.
>
> You want to do:
>
> $sel->remove($agent_sock);
> close $agent_sock;

That did it! Soon as I added the $sel->remove for the two sockets
everything worked as it should. I should be able to incorporate this
into my project now.

I did try this initially, but did the $sel->remove *after* I closed the
socket.

close $agent_sock;
$sel->remove($agent_sock);

That caused the test program to break (input would not echo to the
other console). I'm guessing using strict, warnings, and checking
system call success would tell me why. Placing the $sel-remove *before*
I close the socket, as you suggest, works.

Thank you so much for your help, I really do appreciate it. :)

.



Relevant Pages

  • Re[2]: accounting with ipfw (gid, uid riles)
    ... MS> The uid associated with a socket is the uid of the process which created ... it's still accounted to root. ... far, is adding alias interface, bind squid to this interface and count ...
    (FreeBSD-Security)
  • Re: Recent bad dental experience
    ... Root fragments are left behind on occasion and healing will ... During the extraction the dentist said the tooth broke up into many ... index finger to feel if there was any food material in the socket. ... my surprise, I felt a small, hard, loose fragment, which I was able to ...
    (sci.med.dentistry)
  • Re[2]: accounting with ipfw (gid, uid riles)
    ... But I wanted to count Squid traffic. ... If squid runs the listen as root, all sockets created from that listen ... socket will also be accounted to root. ... not know how natd would affect connections in terms of uid accounting. ...
    (FreeBSD-Security)
  • Re: How to delete unix socket entries
    ... > respond to incoming connections, so that after the socket was opened, the ... root screen 30084 4 stream /tmp/screens/S-paul/30084.ttyp0.hannibal ... root pure-ftp 22112 3 dgram syslogd:3 ...
    (freebsd-hackers)
  • Re: Socket access to low numbered ports?
    ... > listen on those socket without runing as root when doing anything else? ... The standard practice is to make the program setuid, be root just long ... And you can change users in Python like this: ... UID 2 is normally the daemon user. ...
    (comp.lang.python)