Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: In perl socket programming how to send a data from client and receive it from server and how to get number of clients processes and client ID?

by hippo (Bishop)
on May 01, 2019 at 07:44 UTC ( #1233220=note: print w/replies, xml ) Need Help??


in reply to In perl socket programming how to send a data from client and receive it from server and how to get number of clients processes and client ID?

how can I get the client ID and client count at server script?

You already have the client count because you are storing a running count of the file descriptors in @clients and therefore the client count is scalar @clients (or $#clients + 1 if you prefer). As for the client ID it depends entirely what you mean by that.

open my $fh, ">&=$fn" or warn $! and die;

Can you explain why you warn $! and die here rather than just die $!?

  • Comment on Re: In perl socket programming how to send a data from client and receive it from server and how to get number of clients processes and client ID?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: In perl socket programming how to send a data from client and receive it from server and how to get number of clients processes and client ID?
by choroba (Archbishop) on May 01, 2019 at 07:52 UTC
    Maybe the problem is the number of clients doesn't decrease when a client disconnects? It's possible to send a "goodbye" message to the server, but sometimes the connection gets lost without a chance to say anything, in which case a timeout (and maybe a keep-alive message) might help. Also, why is the initial number of clients set to -1?

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1233220]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2021-10-28 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (96 votes). Check out past polls.

    Notices?