1

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:

#!/bin/sh
nc -lvk 88.109.110.161 100 > port100.txt 2>&1

As client I send the request:

echo "Hello" | nc 88.109.110.161 100

And the file is populated with:

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

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.