Basic Server
Problem
You want to provide a service over a network.
Solution
Create a basic TCP server.
In Node.js
Example Usage
Accessed by the Basic Client:
Discussion
The function passed to @net.createServer@ receives the new socket provided for each new connection to a client. This basic server simply socializes with its visitors but a hard-working server would pass this socket along to a dedicated handler and then return to the task of waiting for the next client.
See also the Basic Client, Bi-Directional Server, and Bi-Directional Client recipes.
Exercises
- Add support for choosing the target domain and port based on command-line arguments or from a configuration file.