aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-08-10 20:28:30 +0200
committerLoïc Hoguin <[email protected]>2011-08-10 20:28:30 +0200
commit43d14b52cd07dfd1121bbe6727a96dfd32304e47 (patch)
tree5b8d451d0decec8e75cf70c24e5c3fb54f51a65c /README.md
parent56369d5c1a0a3141e9d136b2f8010ff0e96bb26c (diff)
downloadcowboy-43d14b52cd07dfd1121bbe6727a96dfd32304e47.tar.gz
cowboy-43d14b52cd07dfd1121bbe6727a96dfd32304e47.tar.bz2
cowboy-43d14b52cd07dfd1121bbe6727a96dfd32304e47.zip
Give the ListenerPid to the protocol on startup
Also sends a message 'shoot' that can be received by the protocol to make sure Cowboy has had enough time to fully initialize the socket. This message should be received before any socket-related operations are performed. WebSocket request connections are now moved from the pool 'default' to the pool 'websocket', meaning we can have a lot of running WebSockets despite having a low 'max_connections' setting.
Diffstat (limited to 'README.md')
-rw-r--r--README.md14
1 files changed, 9 insertions, 5 deletions
diff --git a/README.md b/README.md
index 5933481..350ce44 100644
--- a/README.md
+++ b/README.md
@@ -219,11 +219,15 @@ One of the strengths of Cowboy is of course that you can use it with any
protocol you want. The only downside is that if it's not HTTP, you'll
probably have to write the protocol handler yourself.
-The only exported function a protocol handler needs is the start_link/3
-function, with arguments Socket, Transport and Opts. Socket is of course
-the client socket; Transport is the module name of the chosen transport
+The only exported function a protocol handler needs is the start_link/4
+function, with arguments ListenerPid, Socket, Transport and Opts. ListenerPid
+is the pid to the listener's gen_server, managing the connections. Socket is of
+course the client socket; Transport is the module name of the chosen transport
handler and Opts is protocol options defined when starting the listener.
-Anything you do past this point is up to you!
+
+After initializing your protocol, it is recommended to wait to receive a message
+containing the atom 'shoot', as it will ensure Cowboy has been able to fully
+initialize the socket. Anything you do past this point is up to you!
You should definitely look at the cowboy_http_protocol module for a great
example of fast request handling if you need to. Otherwise it's probably
@@ -231,7 +235,7 @@ safe to use `{active, once}` mode and handle everything as it comes.
Note that while you technically can run a protocol handler directly as a
gen_server or a gen_fsm, it's probably not a good idea, as the only call
-you'll ever receive from Cowboy is the start_link/3 call. On the other
+you'll ever receive from Cowboy is the start_link/4 call. On the other
hand, feel free to write a very basic protocol handler which then forwards
requests to a gen_server or gen_fsm. By doing so however you must take
care to supervise their processes as Cowboy only knows about the protocol