1ssh_server_channel(3)      Erlang Module Definition      ssh_server_channel(3)
2
3
4

NAME

6       ssh_server_channel - -behaviour(ssh_server_channel). (Replaces ssh_dae‐
7       mon_channel)
8
9

DESCRIPTION

11   Note:
12       This module replaces ssh_daemon_channel.
13
14       The old module is still available for compatibility, but should not  be
15       used for new programs. The old module will not be maintained except for
16       some error corrections
17
18
19       SSH services (clients and servers) are implemented as channels that are
20       multiplexed  over an SSH connection and communicates over the  SSH Con‐
21       nection Protocol. This module provides a callback API that  takes  care
22       of  generic channel aspects for daemons, such as flow control and close
23       messages. It lets the callback  functions  take  care  of  the  service
24       (application) specific parts. This behavior also ensures that the chan‐
25       nel process honors the principal of an OTP-process so that  it  can  be
26       part  of  a supervisor tree. This is a requirement of channel processes
27       implementing a subsystem that will be added  to  the  ssh  applications
28       supervisor tree.
29
30   Note:
31       When   implementing   a   client   subsystem   handler,   use   -behav‐
32       iour(ssh_client_channel) instead.
33
34

CALLBACK FUNCTIONS

36       The following functions are to be exported  from  a  ssh_server_channel
37       callback module.
38

EXPORTS

40       Module:init(Args) -> {ok, State} | {ok, State, timeout()} | {stop, Rea‐
41       son}
42
43              Types:
44
45                 Args = term()
46                   Last argument to start_link/4.
47                 State = term()
48                 Reason = term()
49
50              Makes necessary initializations and returns the initial  channel
51              state if the initializations succeed.
52
53              The time-out values that can be returned have the same semantics
54              as in a gen_server. If  the  time-out  occurs,  handle_msg/2  is
55              called as handle_msg(timeout, State).
56
57       Module:handle_msg(Msg, State) -> {ok, State} | {stop, ChannelId, State}
58
59              Types:
60
61                 Msg = timeout | term()
62                 ChannelId = ssh:channel_id()
63                 State = term()
64
65              Handles  other  messages  than SSH Connection Protocol, call, or
66              cast messages sent to the channel.
67
68              Possible Erlang 'EXIT' messages is to be handled by  this  func‐
69              tion and all channels are to handle the following message.
70
71                {ssh_channel_up, ssh:channel_id(), ssh:connection_ref()}:
72                  This is the first message that the channel receives. This is
73                  especially useful if the server wants to send a  message  to
74                  the client without first receiving a message from it. If the
75                  message is not useful for your particular  scenario,  ignore
76                  it by immediately returning {ok, State}.
77
78       Module:handle_ssh_msg(Msg,  State)  ->  {ok, State} | {stop, ChannelId,
79       State}
80
81              Types:
82
83                 Msg = ssh_connection:event()
84                 ChannelId = ssh:channel_id()
85                 State = term()
86
87              Handles SSH Connection Protocol messages that may need  service-
88              specific attention. For details, see ssh_connection:event().
89
90              The following message is taken care of by the ssh_server_channel
91              behavior.
92
93                {closed, ssh:channel_id()}:
94                  The channel behavior sends a  close  message  to  the  other
95                  side,  if  such a message has not already been sent. Then it
96                  terminates the channel with reason normal.
97
98       Module:terminate(Reason, State) -> _
99
100              Types:
101
102                 Reason = term()
103                 State = term()
104
105              This function is called by a channel process when it is about to
106              terminate.   Before   this   function  is  called,   ssh_connec‐
107              tion:close/2  is called, if it has not been called earlier. This
108              function  does  any  necessary cleaning up. When it returns, the
109              channel process terminates with reason Reason. The return  value
110              is ignored.
111
112
113
114Ericsson AB                         ssh 4.8              ssh_server_channel(3)
Impressum