# Module comm_connection

- Description
- Data Types
- Function Index
- Function Details

creates and destroys connections and represents the endpoint of a connection where messages are received from and send to the network.

Copyright © 2007-2015 Zuse Institute Berlin

Version: $Id$

Behaviours: `gen_component`.

Authors: Thorsten Schuett (`schuett@zib.de`), Florian Schintke (`schintke@zib.de`).

## Description

creates and destroys connections and represents the endpoint of a connection where messages are received from and send to the network.

## Data Types

### erlang_timestamp()

    erlang_timestamp() =
        {MegaSecs :: non_neg_integer(),
         Secs :: 0..999999,
         MicroSecs :: 0..999999}

### message()

    message() =
        {send,
         DestPid :: pid(),
         Message :: comm:message(),
         Options :: comm:send_options()} |
        {tcp, Socket :: inet:socket(), Data :: binary()} |
        {tcp_closed, Socket :: inet:socket()} |
        {report_stats} |
        {web_debug_info, Requestor :: comm:erl_local_pid()}

### msg_or_tag()

    msg_or_tag() = comm:message() | comm:msg_tag()

### msg_queue()

    msg_queue() =
        {MQueue :: [{DestPid :: pid(), Message :: comm:message()}],
         OQueue :: [comm:send_options()]}

### stat_report()

    stat_report() =
        {RcvCnt :: non_neg_integer(),
         RcvBytes :: non_neg_integer(),
         SendCnt :: non_neg_integer(),
         SendBytes :: non_neg_integer()}

### state()

    state() =
        {DestIP :: inet:ip_address(),
         DestPort :: comm_server:tcp_port(),
         LocalListenPort :: comm_server:tcp_port(),
         Channel :: comm:channel(),
         Socket :: inet:socket() | notconnected,
         StartTime :: erlang_timestamp(),
         SentMsgCount :: non_neg_integer(),
         ReceivedMsgCount :: non_neg_integer(),
         MsgQueue :: msg_queue(),
         MsgQueueLen :: non_neg_integer(),
         DesiredBundleSize :: non_neg_integer(),
         MsgsSinceBundleStart :: non_neg_integer(),
         LastStatReport :: stat_report(),
         TimeLastMsgSent :: time_last_msg(),
         TimeLastMsgReceived :: time_last_msg(),
         SentMsgCountSession :: non_neg_integer(),
         ReceivedMsgCountSession :: non_neg_integer(),
         SessionCount :: non_neg_integer(),
         LastMsgSent :: [msg_or_tag()],
         LastMsgReceived :: [msg_or_tag()]}

### time_last_msg()

    time_last_msg() = erlang_timestamp()

## Function Index

init/1 | initialize: return initial state.
on/2 | message handler.
start_gen_component/5 |
start_link/6 |

## Function Details

### start_gen_component/5

    start_gen_component(Module :: module(),
                        Handler :: gen_component:handler(),
                        Args :: term(),
                        Options :: [gen_component:option()],
                        Self :: pid()) ->
                           no_return() | ok

### start_link/6

    start_link(CommLayerGroup :: pid_groups:groupname(),
               DestIP :: inet:ip_address(),
               DestPort :: comm_server:tcp_port(),
               Socket :: inet:socket() | notconnected,
               Channel :: comm:channel(),
               Dir :: rcv | send | both) ->
                  {ok, pid()}

### init/1

    init(X1 ::
             {DestIP :: inet:ip_address(),
              DestPort :: comm_server:tcp_port(),
              LocalListenPort :: comm_server:tcp_port(),
              Channel :: comm:channel(),
              Socket :: inet:socket() | notconnected}) ->
            state()

initialize: return initial state.

### on/2

    on(UnknownMessage :: message(), State :: state()) -> state()

message handler

Generated by EDoc, Feb 29 2016, 16:12:14.