Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

a host/client chat program

by hnd (Scribe)
on Jun 30, 2009 at 12:36 UTC ( #776012=CUFP: print w/replies, xml ) Need Help??

hello everyone.....
when i went to hostel my parents used to call me every other minute espl my sister....
once my father told me that the phone bill has increased at least five fold
so i decided to make a chatting software so that we can talk anytime.......
here it goes
the host
use IO::Socket; #use the socket module use strict; #am bit careless so i need this my $socket=new IO::Socket::INET( LocalAddr=>'<my IP>' , LocalPort=>8080, Listen=>1, ) or die "cannot create host\n"; my ($client,$scrap_out,$scrap_in); while($client=$socket->accept()) { while(1) { #now recieve the messeage $scrap_in=<$client>; print "scrap_in:\t$scrap_in\n"; print "scrap_out:\t"; $scrap_out=<>; print $client $scrap_out; if($scrap_out=~/'bye'/i or $scrap_in=~/'bye'/) {close $socket and die "connection closed\n";} } }
the client
use IO::Socket; use strict; print "enter host name to connect to:\t"; my $hostname=<>; my $socket= new IO::Socket::INET( PeerAddr=>$hostname, PeerPort=>8080, Reuse=>1, ) or die "cannot connect to host at this time\n"; my($scrap_in,$scrap_out); while(1) { print "scrap_out:\t"; $scrap_out=<>; print $socket $scrap_out; $scrap_in=<$socket>; print "scrap_in:\t$scrap_in\n"; if($scrap_in=~/'bye'/i or $scrap_out=~/'bye'/i) {close $socket and die "connection ended\n";} }

so this way we chat everyday in the evening and even my dad installed perl and this program in many of his friend's and relative's lappys and he told me that the phone bill is reduced five folds!!!!
coooolll
ps:- the <my ip> string is the ip given to me by my college server and i know this is bit clumsy but this dates back to when i first started network programming in perl

Replies are listed 'Best First'.
Re: a host/client chat program
by toolic (Bishop) on Jun 30, 2009 at 13:32 UTC
    You should post code that someone can download and compile without errors. Try to download the code yourself, and try to run it. Then, fix the syntax errors in both samples. That would be cooolll :) Your 'if' statements are missing curly braces, and your constructor is missing a fat comma (=>) near 'Reuse'.
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2022-01-23 07:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (63 votes). Check out past polls.

    Notices?