nagalenoj has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem in socket
by ikegami (Patriarch) on Dec 03, 2008 at 07:05 UTC | |
by spmlingam (Scribe) on Dec 03, 2008 at 07:17 UTC | |
|
Re: Problem in socket
by zentara (Cardinal) on Dec 03, 2008 at 13:38 UTC |