I am trying to make a tcp server in golang which accepts the connection, reads data and then publishes it via nats.Publish. But I also want to reply and close the connection inside the subsriber not in the main server script I see two possible ways: to publish connection or to make a new one in a subsriber, but I cannot realize either Thank you in advance
UPD A comment regarding I. Kozlovic answer: Not exactly what I wanted but may help :) I was writing about closing tcp connection - not a nats one and to close in another go process - not in the one it was accepted. But as I did not succeeded in it I could do the following basing on your answer: I can publish information I need via nats, process it and then reply with "OK. Close connection" and close the TCP connection in publisher which is a TCP server. However that would be great if I could reply not from this go process but from the another one. Its tricky I understand but I want to do the same I wrote in the previous message but with some modification. I have TCP server, it accepts connection and then connects nats and publishes message, another go process subscribed to this message processes input and then publishes its output to the third go process which processes its input and then replies "OK. Done. Close TCP connection" to the first go process.... :)