Problems with perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems with perl
# 1  
Old 12-20-2006
Data Problems with perl

hi i'm writing multiclient perl server cross plataform
it will redirect one connection to any computer inside mine lan

so when someone connect on this server
it create a socket and connect to the computer
create two threads and read the data incoming from the client
and send to another computer and the reverse.

but when i read one socket it block the another help me plz

here is the main function of the server
Code:
spawn sub {
            $|=1;
	    print "BindRouter>";
	    my $cmd;
	    chop($cmd=<stdin>);
	    my @argz=split(/:/,$cmd);
	    print stderr "Received connection from :",inet_ntoa($iaddr),"\n";
	    my $sock=IO::Socket::INET->new("@argz[0]:@argz[1]");
	    if($sock){
	    print "Connected\n";

	    my $thres = threads->new(\&readx($sock));
	    my $threx = threads->new(\&readf($sock));

		while($sock){
		}
		kill($thres);
		kill($threx);
 	    }else{
	    print "can't connect!\n";
            }

        };

sub readf{
my $socket=@_[0];
my $buf;
while($socket){
$buf=<$socket>;
print $buf;
}
}


sub readx{
my $socket=@_[0];

my $buf;
while($socket){
$buf=<stdin>; #stdin is the client
print $socket $buf;
}

}


how i make to one device don't block another?

Last edited by sendai; 12-20-2006 at 06:04 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problems passing shell arguments to perl

Semi-newbie, so flame throwers to 'singe-only', please. ;-) I have a large number of (say) .html files, where I'd like to do a recursive in-place search and replace a particular string. The following bit of perl works fine: perl -pi -e 's/oldstring/newstring/g' `find ./ -name *.html` ... (2 Replies)
Discussion started by: johnny_canucl
2 Replies

2. Red Hat

Perl problems in RHEL 5.X

Hi, We have RHEL 5.X OS installed here, where we need few Perl modules installed. I have local copy of Perl modules in .tar.gz format. The problem is that we don't have Internet available here and it is really pain to install all the modules manually on all the servers one by one. So can I... (1 Reply)
Discussion started by: nixhead
1 Replies

3. Shell Programming and Scripting

Methods For Debugging Perl Problems

Note: Not a programmer by profession but occasionally have to program. I am looking for general methods and freely/readily available tools employed to debug problems during development of perl scripts. Anything that has really helped you out with problems you just couldn't find. A couple of... (5 Replies)
Discussion started by: Vi-Curious
5 Replies

4. UNIX for Dummies Questions & Answers

Problems with Alt Gr in Perl scripts

Hey I am new to programming in general but am trying to work in Perl. The thing is that almost every time I write a script (I use nedit) I get problems with Alt Gr. E.g. In stead of } I get <gs> or in stead of \ nothing happens. Sometimes it's really bad and when I want a new line then... (1 Reply)
Discussion started by: Banni
1 Replies

5. Shell Programming and Scripting

Perl Print Problems in script

Hi Perl Gurus, perl -e 'print "http://www.site@domain.com"' The output of the above is : http://www.site.com" I want to print http://www.site@domain.com without using escape sequence before '@' like '\@'. Is there any way to do this in perl? Thanks, Som (1 Reply)
Discussion started by: som.nitk
1 Replies

6. Shell Programming and Scripting

Perl - Problems with Signal Handler

I have a problem with signal handlers not working. I have a long 1000 line code and somehow this code for signal handling is not working: $SIG{INT} = \&interrupt; sub interrupt { print STDERR "Caught a control c!\n"; exit; # or just about anything else you'd want to do } Any... (2 Replies)
Discussion started by: som.nitk
2 Replies

7. Shell Programming and Scripting

Problems in running a Perl script via cronjob

I have a very basic perl script that attempts to find if a process is running. If the process is not running then the script is supposed to start the process. If I execute the script from command line it works fine as expected. However if the script is executed via cronjob, the script cannot find... (1 Reply)
Discussion started by: ypant
1 Replies

8. Shell Programming and Scripting

problems with double quotes in PERL

I have a cgi script I run through apache2 and I need to have a line that contains double quotes within double quotes. Here's what I need PERL to pass to rrdtool: HRULE:30#BBBB00:"30.0 constant":dashesIt's a little more complicated since I also have variables in the statement which requires... (13 Replies)
Discussion started by: audiophile
13 Replies

9. Shell Programming and Scripting

Problems with Perl/KSH Web Log Script

Hi, I am writing a series of scripts for work to analyse intranet access logs. All of the scripts do as they should when run individually from the shell, but only when run from certain directories. This sounds like it may be a PATH issue but I am not sure. When I run a certain script, say... (3 Replies)
Discussion started by: mmanders
3 Replies

10. Shell Programming and Scripting

perl Mail::Client::Yahoo problems

hi, im very new to perl and im having problems with a module. my comptuer is behind a firewall and i dont know how to work this problem out. i tried passing my proxy parameters (ip, port, user, pass) to my environment variables but it doesnt seem to work. heres the almost exact code from the... (0 Replies)
Discussion started by: marcpascual
0 Replies
Login or Register to Ask a Question