# How to set up a TCP server on the red node, how to send the information to the client

**URL:** <https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788>\
**Category:** General\
**Created:** [29 July 2022 14:31 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788 "2022-07-29T14:31:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyx101](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kyx101/32/65393_2.png) [@kyx101](https://discourse.nodered.org/u/kyx101)\
**Post date:** [29 July 2022 14:31 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788/1 "2022-07-29T14:31:54Z")

</div>

Establish a TCP server on the red node, how to send information to the client, and use the echo method will cause other ports to be polluted.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 July 2022 15:09 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788/2 "2022-07-29T15:09:17Z")

</div>

> [@kyx101](#):
>
> Establish a TCP server on the red node, how to send information to the client

Have you looked at the tcp-in/-out nodes? They do exactly that.

> [@kyx101](#):
>
> and use the echo method will cause other ports to be polluted.

Not clear what you mean by that. You can inject data before the tcp-out node.

---

<div class="post-metadata">

**Author:** ![kyx101](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kyx101/32/65393_2.png) [@kyx101](https://discourse.nodered.org/u/kyx101)\
**Post date:** [30 July 2022 09:56 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788/3 "2022-07-30T09:56:14Z")

</div>

Using the tcp-to method to establish a server can transmit information to the client, but how to obtain the information sent by the client to the server.

---

<div class="post-metadata">

**Author:** ![kyx101](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kyx101/32/65393_2.png) [@kyx101](https://discourse.nodered.org/u/kyx101)\
**Post date:** [30 July 2022 10:01 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788/4 "2022-07-30T10:01:24Z")

</div>

If the server is established in the in-tcp mode, the information sent by the client can be obtained, but the server can only use the to-tcp response tcp to send information to the client, which will cause the information to be sent on other ports synchronously. . Moreover, in-tcp and to-tcp cannot establish a server with the same port at the same time, and can only use the method of responding to tcp.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 July 2022 11:32 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788/5 "2022-07-30T11:32:23Z")

</div>

> [@kyx101](#):
>
> how to obtain the information sent by the client to the server.

That is available as the output from the tcp-in node, simply feed that output to your flow.

> [@kyx101](#):
>
> in-tcp and to-tcp cannot establish a server with the same port at the same time

That will always be the case for any server since you can only ever have a single address:port combination. To set up a tcp "server" you need a pair of in/out nodes but the out node can also be used separately if you want to connect to another tcp server.

You might also be able to use a reverse proxy such as NGINX to help. It can proxy and load balance TCP services. This may work for you depending on what you are actually trying to achieve.

> [@kyx101](#):
>
> to-tcp response tcp to send information to the client

If the remote client maintains the tcp connection, you should be able to continue to send data via the paired out node. Similarly, a new connection can trigger other information to be added to the return as long as you respond within a reasonable time.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 September 2022 11:32 UTC](https://discourse.nodered.org/t/how-to-set-up-a-tcp-server-on-the-red-node-how-to-send-the-information-to-the-client/65788/6 "2022-09-28T11:32:26Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
