May 09, 2021 CoffeeScript
You want to use the services provided on the network.
Create a basic TCP client.
net = require 'net'
domain = 'localhost'
port = 9001
connection = net.createConnection port, domain
connection.on 'connect', () ->
console.log "Opened connection to #{domain}:#{port}."
connection.on 'data', (data) ->
console.log "Received: #{data}"
connection.end()
Basic Server is accessible:
$ coffee basic-client.coffee
Opened connection to localhost:9001
Received: Hello, World!
The most important work occurs during connection.on 'data' processing, when the client receives a response from the server and is most likely to schedule an answer to it.
See also Basic Server, Bi-Directional Client, and Bi-Directional Server.