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

  • SEARCH
  • Home
  • 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 7063227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:41:20+00:00 2026-05-28T04:41:20+00:00

On HostA, I have a process, procA , that does I/O, like so: #!/bin/bash

  • 0

On HostA, I have a process, procA, that does I/O, like so:

#!/bin/bash
while sleep 1 ; do
  # Consume input *if available*
  if read -t 0.5 x; then  # a timed-read
    # If input is available, output it.
    echo "HostA Input: $x"
  fi

  # Produce some output.
  echo "HostA Output: $(date)"
done

On HostB, I have a very similar process, procB, with the only difference that procB tags its input/output with the prefix HostB (instead of the prefix HostA).

Now, I want to use the netcat program (/usr/bin/nc) to send procA‘s stdout to procB‘s stdin, and procB‘s stdout to procA‘s stdin. My expectation in all this is that HostA’s output should appear on HostB, and HostB’s output should appear on HostA… much as would happen in following canonical nc example of a peer-to-peer chat:

[HostB]$ nc -l 4000

[HostA]$ nc HostB 4000

But, when I tried to extend the above canonical example by replacing the human at both hosts with processes procA and procB as follows, it did not work:

On HostB:

$ mkfifo p
$ ./procB <p | nc -l 4000 >p
<WHY NO OUTPUT HERE??>

and, on HostA:

$ mkfifo p
$ ./procA <p | nc HostB 4000 >p
<WHY NO OUTPUT HERE??>

Notes:

  1. I have verified that port 4000 is open on HostB.
  2. Unidirectional communication, such as the following, seems to work:

On HostB:

$ mkfifo p
$ ./procB <p | nc -l 4000 >p

On HostA:

$ ./procA | nc HostB 4000 
HostB Output: Wed Jan 11 13:53:37 IST 2012
HostB Output: Wed Jan 11 13:53:39 IST 2012
HostB Input: HostA Output: Wed Jan 11 13:55:02 IST 2012
HostB Output: Wed Jan 11 13:53:40 IST 2012
HostB Input: HostA Output: Wed Jan 11 13:55:04 IST 2012
HostB Output: Wed Jan 11 13:53:41 IST 2012
HostB Input: HostA Output: Wed Jan 11 13:55:05 IST 2012
HostB Output: Wed Jan 11 13:53:42 IST 2012
^C

Now, I know that nc comes with an INSECURE option -e that could somehow be employed if it’s enabled in your nc binary, but assuming that I don’t have -e option available, how can I connect 2 remote processes to each other via nc? Basically, where I’m going wrong above? Why there is no output in the places I have indicated above? Many thanks in advance.

  • 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-28T04:41:20+00:00Added an answer on May 28, 2026 at 4:41 am

    The behavior described above is actually the right behavior, just that I did not realize that it was.

    Wherever I was complaining about <WHY NO OUTPUT HERE??>, it was/is because the stdout’s of the terminals have been redirected to the local fifos. (No wonder, you don’t see anything on the terminal!)

    Further, in Notes (2) above, it is not really true that the communication is unidirectional; it is very much bidirectional, just that you don’t get to see any output on HostB, once again, because stdin and stdout have redirected from the terminal to the fifo. Thus, you correctly see procB‘s output on HostA, which is nothing but the output of procA on HostA sent to procB on HostB as procB‘s input!

    Wow!

    EDIT:
    To actually see the output on each terminal, use tee, like so:

    On HostB:

    $ mkfifo p
    $ ./procB <p | nc -l 4000 | tee p
    

    On HostA:

    $ mkfifo p
    $ ./procA <p | nc HostB 4000 | tee p
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the scenario: I'd like to have a host class that can have a
I have a process within a network that wants to talk to a service
I have a process, let's call it Process A, that is hosting a simple
I have a Ruby on Rails app that needs process many background jobs simultaneously:
I have android code that uses a background process to routinely (e.g. hourly) connect
I have a fairly simple process running that periodically pulls RSS feeds and updates
I have a somewhat large server process written in .net-3.5, that is, running in
Started to have an issue this afternoon with the delayed_job process, found that the
I have a process that is supposed to ftp a file to a remote
I have a WCF host that listen to a topic and process incoming messages.

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.