Configuration.listen()
Description
Creates a port pipeline layout for incoming TCP/UDP connections on a port.
A port pipeline has the following input/output:
- INPUT - Data stream received from the client.
- OUTPUT - Data stream to send to the client.
Ports can be specified with just numbers when binding to 0.0.0.0, or strings in form of <IP>:<port> when binding to arbitrary IP addresses. Note that, to bind to an IPv6 address, surround the address within a pair of brackets so that the colon before the port number can be identified correctly, e.g. [::]:8080.
After calling this method on a Configuration, the newly created pipeline layout would become current. Any filter-creating methods called after this point would append filters to that pipeline layout, until another pipeline-layout-creating method is called.
Syntax
pipy().listen(port).filterA().filterB()// ...pipy().listen(port, { ...options }).filterA().filterB()// ...
Parameters
listen(port, options?)
Port number to listen on, or null to skip this pipeline layout.
Options including:
- protocol - Can be "tcp" or "udp". Default is "tcp".
- maxPacketSize - Maximum packet size when using UDP. Default is 16KB.
- maxConnections - Maximum number of concurrent connections. Default is -1, which means unlimited.
- readTimeout - Timeout duration for reading. Can be a number in seconds or a string with one of the time unit suffixes such as s, m or h. Defaults to no timeout (waiting forever).
- writeTimeout - Timeout duration for writing. Can be a number in seconds or a string with one of the time unit suffixes such as s, m or h. Defaults to no timeout (waiting forever).
- idleTimeout - Time in seconds before connection is closed due to no active reading or writing. Can be a number in seconds or a string with one of the time unit suffixes such as s, m or h. Defaults to 1 minute.
- transparent - Set to true to enable transparent proxy mode, where the original destination address and port can be found through __inbound.destinationAddress and __inbound.destinationPort properties. This is only available on Linux by using NAT or TPROXY.
- masquerade - Set to true to change the source address of responding UDP packets to the original destination.
The same Configuration object.
Example
pipy().listen(8080) // Start listening on port 8080.dump() // Add filter, dump to stdout whatever is received from the port.dummy() // Add filter, do not send anything back to the client