# Replace port with TCP In

**URL:** <https://discourse.nodered.org/t/replace-port-with-tcp-in/68268>\
**Category:** General\
**Created:** [27 September 2022 02:49 UTC](https://discourse.nodered.org/t/replace-port-with-tcp-in/68268 "2022-09-27T02:49:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lastheim](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@lastheim](https://discourse.nodered.org/u/lastheim)\
**Post date:** [27 September 2022 02:49 UTC](https://discourse.nodered.org/t/replace-port-with-tcp-in/68268/1 "2022-09-27T02:49:01Z")

</div>

Hi,

How do replace the **port** in below code to the output from a TCP in node? I want the piping part to work in below code...

import { connect } from 'net'

// substitute 192.168.4.1 with the IP address of your module  
**const port = connect({ host: '192.168.4.1', port: 2323 })**

// constructing a reader that will emit each packet separately  
const reader = port  
.pipe(new MavLinkPacketSplitter())  
.pipe(new MavLinkPacketParser())

reader.on('data', packet =\> {  
console.log(packet)  
})

This is what I have now:

`[{"id":"54935c6833928015","type":"function","z":"a473154c2f0f0272","name":"function 3","func":"const mavlink = global.get('mavlink')\n\nmsg.packet = new mavlink.MavLinkPacketSplitter(msg.payload);\nmsg.packet2 = new mavlink.MavLinkPacketParser(msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":680,"wires":[[]]},{"id":"f7146e0c7d21bb61","type":"tcp in","z":"a473154c2f0f0272","name":"","server":"client","host":"192.168.1.124","port":"8888","datamode":"stream","datatype":"buffer","newline":"","topic":"","trim":false,"base64":false,"tls":"","x":200,"y":280,"wires":[["54935c6833928015"]]}]`

---

<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:** [26 November 2022 02:49 UTC](https://discourse.nodered.org/t/replace-port-with-tcp-in/68268/2 "2022-11-26T02:49:19Z")

</div>

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