diff options
author | Andrew Thompson <[email protected]> | 2012-09-24 13:32:21 -0400 |
---|---|---|
committer | Andrew Thompson <[email protected]> | 2012-12-20 12:50:22 -0500 |
commit | 036fbd53189f0a43bd8348e517a17da0f00de980 (patch) | |
tree | 721b2159b79869459af39398f95e1fc38c9397c9 /guide/listeners.md | |
parent | f26401af19bddd74ddd1755041372c737a995b01 (diff) | |
download | ranch-036fbd53189f0a43bd8348e517a17da0f00de980.tar.gz ranch-036fbd53189f0a43bd8348e517a17da0f00de980.tar.bz2 ranch-036fbd53189f0a43bd8348e517a17da0f00de980.zip |
Add {socket, Socket} transport option, for accepting on existing sockets
Diffstat (limited to 'guide/listeners.md')
-rw-r--r-- | guide/listeners.md | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/guide/listeners.md b/guide/listeners.md index 1f7c430..48ec622 100644 --- a/guide/listeners.md +++ b/guide/listeners.md @@ -113,6 +113,24 @@ We recommend the use of port rewriting for systems with a single server, and load balancing for systems with multiple servers. Documenting these solutions is however out of the scope of this guide. +Accepting connections on an existing socket +------------------------------------------- + +If you want to accept connections on an existing socket, you can use the +`socket` transport option, which should just be the relevant data returned +from the connect() function for the undelying socket library +(gen_tcp:connect(), ssl:connect()). accept() will be then be called on the +passed in socket. You should connect() the socket in {active, false} mode, as +well. + +Note, however, that because of a bug in SSL, you cannot change ownership of an +SSL listen socket prior to R16. Ranch will catch the error thrown, but the +owner of the SSL socket will remain as whatever process created the socket. +However, this will not affect accept() behaviour unless the owner process dies, +in which case the socket is closed. Therefore, to use this feature with SSL +with an erlang release prior to R16, ensure that the SSL socket is opened in a +persistant process. + Limiting the number of concurrent connections --------------------------------------------- |