# Create a TCP server and send messages to client

**URL:** https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462
**Category:** General
**Created:** [16 May 2023 12:14 UTC](https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462 "2023-05-16T12:14:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![andre\_x](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@andre\_x](https://discourse.nodered.org/u/andre_x)
#### Post date: [16 May 2023 12:14 UTC](https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462/1 "2023-05-16T12:14:35Z")

</div>

I need to create a TCP server to which a media player software (Coolux Pandoras Box) will connect.  
This is simple, but I should use that same server to send commands to the client...how do I do that?  
Thanks!

---

<div class="post-metadata">

### Author: ![andre\_x](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@andre\_x](https://discourse.nodered.org/u/andre_x)
#### Post date: [16 May 2023 14:26 UTC](https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462/2 "2023-05-16T14:26:37Z")

</div>

I guess that I should send the command to the TCP port that the client uses to connect to the server, but the TCP out node doesn't support dynamic ports...  
And the clients that connects to Node Red TCP server doesn't send anything, so I don't know the port which the connection starts from.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 May 2023 16:49 UTC](https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462/3 "2023-05-16T16:49:02Z")

</div>

Well the client must connect to a known port on your (Node-RED) server - so you must know what that is... it can't just connect randomly.

---

<div class="post-metadata">

### Author: ![andre\_x](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@andre\_x](https://discourse.nodered.org/u/andre_x)
#### Post date: [16 May 2023 16:50 UTC](https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462/4 "2023-05-16T16:50:40Z")

</div>

Of course i know the port which the clients connects to, but I don't know the port the clients connects from to send it the command

---

<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: [15 July 2023 16:50 UTC](https://discourse.nodered.org/t/create-a-tcp-server-and-send-messages-to-client/78462/5 "2023-07-15T16:50:54Z")

</div>

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