Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: bebonhamPosted on 2007-03-22 at 16:20:37ID: 18775763
try it using regular sockets, no module. I never got those modules working.
');
#!/usr/bin/perl -w
use Socket;
# Open LOG file for debug
open (LOG,">>/tmp/log.txt");
#Open socket
my $port=3319;
my $proto=getprotobyname('tcp
socket(Server, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l",1)) or die "setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) or die "bind: $!";
listen(Server,SOMAXCONN) or die "listen: $!";
my $paddr;
my $ID;
# Next we need to wait so long, that we receive a string "PROG_ID xxxxxxx" ,where xxxx is a some ASCII string. Time to wait is from few seconds to 6 hours
for( ; $paddr = accept(Client, Server); close Client)
{
my($port, $iaddr) = sockaddr_in($paddr);
my $buff;
my $string_size =14; ####PLEASE PUT HOW BIG THE STRING IS FROM THE CLIENT
while(read Client, $buff, $string_size)
{
$ID.=$buff;
print LOG "From socket $ID\n"; # Are we getting any
if ($ID =~ /^PROG_ID/)
{
print LOG "IF-LAUSEESSA: $ID\n";
$ID =~ s/PROGRAM_START //; #RIP off "PROG_ID and leave only ASCII string
print LOG "ASCII ID is: $ID\n";
$ID="";
}
}
}