Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:18:36+00:00 2026-05-27T06:18:36+00:00

I have two Perl scripts that are supposed to do the following job: Server

  • 0

I have two Perl scripts that are supposed to do the following job:

Server starts and wait for the client to connect.
The client connects and istantly send an XML file.
Server reads XML file and starts a couple of threads.
Each thread receive $client socket as a parameter and once they’re done they have to send the output back to the client.
Meanwhile the client is waiting for messages to arrive, he’s supposed to print those messages on the command line.

Now my problem is that I don’t know how to implement the last part. I tryed to use the receive method but both programs get stuck if I do that.

Server side:

my @threads;
$server = IO::Socket::INET->new(
            Listen => 1,                
            LocalAddr => 'localhost', 
            LocalPort => '8080', 
            Proto => 'tcp'
) or die "Can't crete socket!\n";
$client = $server->accept;
open FILE, ">".$filename or die "Can't open file!\n";
while (<$client>) {
    print FILE $_;  
}
close FILE;

# READ FILE AND DO SOME OTHER STUFFS
push @threads, threads ->create(\&subroutine1, $parameters, $client);
# OTHER STUFFS
push @threads, threads ->create(\&subroutine2, $parameters, $client);
# MORE THREADS...

sub subroutine1 {
    my @pars= @_;
    my $parameters = $pars[0];
    my $client = $pars[1];
    my $sub1 = `perl other_script.pl $parameters`;
    $client->send($mem);
}

Client side:

my $server = IO::Socket::INET->new(
    PeerAddr => 'localhost',
    PeerPort => '8080',
    Proto => 'tcp'
) or die "Can't create client socket!\n";
open FILE, $filename;
while (<FILE>) {
    print $server $_;   
}
close FILE;
# HOW DO I READ INFORMATIONS?
$server->close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:18:37+00:00Added an answer on May 27, 2026 at 6:18 am

    You cannot put the send part into the children/worker threads, it’ll be jumbled.

    Q: Why did the multi-threaded chicken cross the road?

    A: other to side. To the get

    Instead, have the parent/boss thread collect the results of the children, sort the data if necessary, serialise, then send as a whole.

    You read with the recv function, also available as a method in IO::Socket.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two processes: a server that should be run in background, but starts
I have two perl scripts; one acts like the client (and queries); the other
I have 5 Perl files that are verification scripts for 5 different states of
I have a Perl script that requires two command line arguments that takes a
I have a Perl script that has two dependencies that exist in CPAN. What
I have two Perl files: action.pl and the other is test.pl action.pl has a
I want to parse a large XML file and I have two options: Perl
I have two folders php and perl . They contain index.php and index.pl ,
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove
I have the opportunity to take a two day class on Perl 6 with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.