I am trying to create a socket where the client receives a response based on their request, but I can not figure out how to achieve this on CentOS 7.

Until now I have the socket opened on port 100 and saving the client request in a file:

nc -lvk 100 > port100.txt 2>&1

As client I send the request:

echo "Hello" | nc 100

And the file is populated with:

Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Listening on
Ncat: Connection from
Ncat: Connection from

I want the client receive the response based on the query, if the request is Hello, then receive World, if World then Hello. How can I do that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.