README.md
1Connection
2==========
3
4`Connection` behaviour for connection processes. The API is superset of the
5GenServer API. There are 2 additional callbacks `connect/2` and `disconnect/2`:
6
7```elixir
8 @callback init(any) ::
9 {:ok, any} | {:ok, any, timeout | :hibernate} |
10 {:connect, any, any} |
11 {:backoff, timeout, any} | {:backoff, timeout, any, timeout | :hibernate} |
12 :ignore | {:stop, any}
13
14 @callback connect(any, any) ::
15 {:ok, any} | {:ok, any, timeout | :hibernate} |
16 {:backoff, timeout, any} | {:backoff, timeout, any, timeout | :hibernate} |
17 {:stop, any, any}
18
19 @callback disconnect(any, any) ::
20 {:connect, any, any} |
21 {:backoff, timeout, any} | {:backoff, timeout, any, timeout | :hibernate} |
22 {:noconnect, any} | {:noconnect, any, timeout | :hibernate}
23 {:stop, any, any}
24
25 @callback handle_call(any, {pid, any}, any) ::
26 {:reply, any, any} | {:reply, any, any, timeout | :hibernate} |
27 {:noreply, any} | {:noreply, any, timeout | :hibernate} |
28 {:disconnect | :connect, any, any} |
29 {:disconnect | :connect, any, any, any} |
30 {:stop, any, any} | {:stop, any, any, any}
31
32 @callback handle_cast(any, any) ::
33 {:noreply, any} | {:noreply, any, timeout | :hibernate} |
34 {:disconnect | :connect, any, any} |
35 {:stop, any, any}
36
37 @callback handle_info(any, any) ::
38 {:noreply, any} | {:noreply, any, timeout | :hibernate} |
39 {:disconnect | :connect, any, any} |
40 {:stop, any, any}
41
42 @callback code_change(any, any, any) :: {:ok, any}
43
44 @callback terminate(any, any) :: any
45```
46There is an example of a simple TCP connection process in
47`examples/tcp_connection/`.
48