nagalenoj has asked for the wisdom of the Perl Monks concerning the following question:
Dear friends,
I have written a simple client-server program. As, I need multiplexing, I used select function. When the server's fd is ready to read, I accept the new clients. Fortunately, Every thing is working fine.
After accepting the client, I am printing a message, "New client connected". The print is not working.
I checked the /proc/<pid>/fd directory, to check whether the STDOUT is closed. But, the stdout is opened.
The code piece, print "Before select\n"; # It is getting printed. while (1) { # used select my $count = select($rout = $rin, undef, undef, 0.001); next if($count <= 0); foreach (keys %client_hash) { if(vec($rout, $_, 1) == 1) { # if server then accept if($_ == fileno($SERVER)) { my $paddr = accept(my $Client,$SERVER); $client_hash{fileno($Client)} = $Client; $client_hash_values{fileno($Client)} = $paddr; print "New Client Connected\n" ; vec($rin, fileno($Client), 1) = 1; next; }
Back to
Seekers of Perl Wisdom