Skip to main content
added 2 characters in body
Source Link
Alexander Mills
  • 10.9k
  • 27
  • 120
  • 214

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do I respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?

My only guess is to have two servers:

nc -lk -U /my/fifo1 | while read line; do

  # muh custom logic goes here mmmkay

done > nc -lk -U /my/fifo2

so then clients connect with:

echo '{"client_id":123}' | nc -U /my/fifo1 

nc -U /my/fifo2 | while read line; do

done; 

this betrays what I know about how tcp and unix domain sockets work with Node.js etc, but I guess with bash we have to do it this way?

I also think to avoid race conditions might have to put the above two commands in a single pipe somehow.

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?

My only guess is to have two servers:

nc -lk -U /my/fifo1 | while read line; do

  # muh custom logic goes here mmmkay

done > nc -lk -U /my/fifo2

so then clients connect with:

echo '{"client_id":123}' | nc -U /my/fifo1 

nc -U /my/fifo2 | while read line; do

done; 

this betrays what I know about how tcp and unix domain sockets work with Node.js etc, but I guess with bash we have to do it this way?

I also think to avoid race conditions might have to put the above two commands in a single pipe somehow.

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do I respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?

My only guess is to have two servers:

nc -lk -U /my/fifo1 | while read line; do

  # custom logic goes here

done > nc -lk -U /my/fifo2

so then clients connect with:

echo '{"client_id":123}' | nc -U /my/fifo1 

nc -U /my/fifo2 | while read line; do

done; 

this betrays what I know about how tcp and unix domain sockets work with Node.js etc, but I guess with bash we have to do it this way?

I also think to avoid race conditions might have to put the above two commands in a single pipe somehow.

added 580 characters in body
Source Link
Alexander Mills
  • 10.9k
  • 27
  • 120
  • 214

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?

My only guess is to have two servers:

nc -lk -U /my/fifo1 | while read line; do

  # muh custom logic goes here mmmkay

done > nc -lk -U /my/fifo2

so then clients connect with:

echo '{"client_id":123}' | nc -U /my/fifo1 

nc -U /my/fifo2 | while read line; do

done; 

this betrays what I know about how tcp and unix domain sockets work with Node.js etc, but I guess with bash we have to do it this way?

I also think to avoid race conditions might have to put the above two commands in a single pipe somehow.

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?

My only guess is to have two servers:

nc -lk -U /my/fifo1 | while read line; do

  # muh custom logic goes here mmmkay

done > nc -lk -U /my/fifo2

so then clients connect with:

echo '{"client_id":123}' | nc -U /my/fifo1 

nc -U /my/fifo2 | while read line; do

done; 

this betrays what I know about how tcp and unix domain sockets work with Node.js etc, but I guess with bash we have to do it this way?

I also think to avoid race conditions might have to put the above two commands in a single pipe somehow.

Source Link
Alexander Mills
  • 10.9k
  • 27
  • 120
  • 214

So here is the thing, I guess I can respond to clients with:

echo "this is the response" | nc -lk -U /my/fifo

but the whole point is how do respond differently depending on who the client is? I mean how can you create something very useful if there is no logic based on the client request etc?