Documented new parameter on the TCP version of the listen API.

This commit is contained in:
Bill Abt
2018-12-13 11:01:32 -05:00
parent 9d77d6b212
commit d95bb3790a
+2 -2
View File
@@ -151,8 +151,8 @@ To close the socket of an open instance, the following function is provided:
### Listen on a socket (TCP/UNIX).
To use **BlueSocket** to listen for an connection on a socket the following API is provided:
- `listen(on port: Int, maxBacklogSize: Int = Socket.SOCKET_DEFAULT_MAX_BACKLOG, allowPortReuse: Bool = true)`
The first parameter `port`, is the port to be used to listen on. The second parameter, `maxBacklogSize` allows you to set the size of the queue holding pending connections. The function will determine the appropriate socket configuration based on the `port` specified. For convenience on macOS, the constant `Socket.SOCKET_MAX_DARWIN_BACKLOG` can be set to use the maximum allowed backlog size. The default value for all platforms is `Socket.SOCKET_DEFAULT_MAX_BACKLOG`, currently set to *50*. For server use, it may be necessary to increase this value. To allow the reuse of the listening port, set `allowPortReuse` to `true`. If set to `false`, a error will occur if you attempt to listen on a port already in use. The `DEFAULT` behavior is to `allow` port reuse.
- `listen(on port: Int, maxBacklogSize: Int = Socket.SOCKET_DEFAULT_MAX_BACKLOG, allowPortReuse: Bool = true, node: String? = nil)`
The first parameter `port`, is the port to be used to listen on. The second parameter, `maxBacklogSize` allows you to set the size of the queue holding pending connections. The function will determine the appropriate socket configuration based on the `port` specified. For convenience on macOS, the constant `Socket.SOCKET_MAX_DARWIN_BACKLOG` can be set to use the maximum allowed backlog size. The default value for all platforms is `Socket.SOCKET_DEFAULT_MAX_BACKLOG`, currently set to *50*. For server use, it may be necessary to increase this value. To allow the reuse of the listening port, set `allowPortReuse` to `true`. If set to `false`, a error will occur if you attempt to listen on a port already in use. The `DEFAULT` behavior is to `allow` port reuse. The last parameter, `node`, can be used to listen on a *specific address*. The value passed is an *optional String* containing the numerical network address (for IPv4, numbers and dots notation, for iPv6, hexidecimal strting). The `DEFAULT` behavior is to search for an appropriate interface. If `node` is improperly formatted a **SOCKET_ERR_GETADDRINFO_FAILED** error will be returned. If `node` is properly formatted but the address specified is not available, a **SOCKET_ERR_BIND_FAILED** will be returned.
- `listen(on path: String, maxBacklogSize: Int = Socket.SOCKET_DEFAULT_MAX_BACKLOG)`
This API can only be used with the `.unix` protocol family. The first parameter `path`, is the path to be used to listen on. The second parameter, `maxBacklogSize` allows you to set the size of the queue holding pending connections. The function will determine the appropriate socket configuration based on the `port` specified. For convenience on macOS, the constant `Socket.SOCKET_MAX_DARWIN_BACKLOG` can be set to use the maximum allowed backlog size. The default value for all platforms is `Socket.SOCKET_DEFAULT_MAX_BACKLOG`, currently set to *50*. For server use, it may be necessary to increase this value.