Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Tk and socket question

by esskar (Deacon)
on Mar 05, 2004 at 01:33 UTC ( [id://334090]=note: print w/replies, xml ) Need Help??


in reply to Tk and socket question

i sugest to
1. use strict;
2. try to build an console based chat before attempting Tk stuff

Replies are listed 'Best First'.
Re: Re: Tk and socket question
by Anonymous Monk on Mar 05, 2004 at 01:51 UTC
    1. i usually do, i just wrote that more as the 'beta'.
    2. already done. see code below.
    use strict; use IO::Socket; use IO::Select; my $listen = IO::Socket::INET->new(Proto => 'tcp', LocalPort => 9192, Listen => 1, Reuse => 1) or die $!; my $select = IO::Select->new($listen); my @ready; while(@ready = $select->can_read) { my $socket; for $socket (@ready) { if($socket == $listen) { my $new = $listen->accept; $select->add($new); print $new->fileno . ": connected\n"; } else { my $line=""; $socket->recv($line,80); if($line eq "") { print $socket->fileno . ": disconnected\n"; $select->remove($socket); $socket->close; }; my $socket; for $socket ($select->handles) { next if($socket==$listen); $socket->send($line) or do { print $socket->fileno . ": disconnected\n"; $select->remove($socket); $socket->close; }; } } } }
    god bless select().
      sorry, that^ was me. and esskar- i didn't think i did such a bad job on my tk.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-24 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found