# Module comm_server

- Description
- Data Types
- Function Index
- Function Details

CommLayer: Management of comm_connection processes, generic functions to send messages.

Copyright © 2008-2015 Zuse Institute Berlin

Version: $Id$

Behaviours: `gen_component`.

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

## Description

CommLayer: Management of comm_connection processes, generic functions to send messages. Distinguishes on runtime whether the destination is in the same Erlang virtual machine (use ! for sending) or on a remote site (send through comm_connection).

## Data Types

### message()

    message() =
        {create_connection,
         Address :: inet:ip_address(),
         Port :: tcp_port(),
         Socket :: inet:socket() | notconnected,
         Channel :: comm:channel(),
         Client :: pid()} |
        {send,
         Address :: inet:ip_address(),
         Port :: tcp_port(),
         Pid :: pid(),
         Message :: comm:message()} |
        {unregister_conn,
         Address :: inet:ip_address(),
         Port :: tcp_port(),
         Client :: pid()} |
        {set_local_address,
         Address :: inet:ip_address(),
         Port :: tcp_port(),
         Client :: pid()}

### process_id()

    process_id() =
        {inet:ip_address(), tcp_port(), comm:erl_local_pid_plain()}

### tcp_port()

    tcp_port() = 0..65535

## Function Index

create_connection/4 | Synchronous call to create (or get) a connection for the given Address+Port using Socket.
get_ip/1 | Gets the IP address of the given process id.
get_local_address_port/0 | returns the local ip address and port.
get_port/1 | Gets the port of the given process id.
init/1 | initialize: return initial state.
is_local/1 |
is_valid/1 |
make_local/1 |
on/2 | message handler.
report_send_error/4 |
send/3 | send message via tcp, if target is not in same Erlang VM.
set_local_address/2 |
start_gen_component/5 |
start_link/1 |
tcp_options/1 |
this/0 | returns process descriptor for the calling process.
unregister_connection/2 | Synchronous call to de-register a connection with the comm server.

## 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

### send/3

    send(Target :: process_id(),
         Message :: comm:message(),
         Options :: comm:send_options()) ->
            ok

send message via tcp, if target is not in same Erlang VM.

### this/0

    this() -> process_id()

returns process descriptor for the calling process

### is_valid/1

    is_valid(X1 :: process_id() | any()) -> boolean()

### is_local/1

    is_local(X1 :: process_id()) -> boolean()

### make_local/1

    make_local(X1 :: process_id()) -> comm:erl_local_pid_plain()

### get_ip/1

    get_ip(X1 :: process_id()) -> inet:ip_address()

Gets the IP address of the given process id.

### get_port/1

    get_port(X1 :: process_id()) -> tcp_port()

Gets the port of the given process id.

### report_send_error/4

    report_send_error(Options :: comm:send_options(),
                      Target :: process_id(),
                      Message :: comm:message(),
                      Reason :: atom()) ->
                         ok

### start_link/1

    start_link(CommLayerGroup :: pid_groups:groupname()) ->
                  {ok, pid()}

### init/1

    init(X1 :: []) -> null

initialize: return initial state.

### on/2

    on(X1 :: message(), State :: null) -> null

message handler

### tcp_options/1

    tcp_options(Channel :: comm:channel()) -> [{term(), term()}]

### create_connection/4

    create_connection(Address :: inet:ip_address(),
                      Port :: tcp_port(),
                      Socket :: inet:socket(),
                      Channel :: comm:channel()) ->
                         pid()

Synchronous call to create (or get) a connection for the given Address+Port using Socket.

### unregister_connection/2

    unregister_connection(Adress :: inet:ip_address(),
                          Port :: tcp_port()) ->
                             ok

Synchronous call to de-register a connection with the comm server.

### set_local_address/2

    set_local_address(Address :: inet:ip_address() | undefined,
                      Port :: tcp_port()) ->
                         ok

### get_local_address_port/0

    get_local_address_port() ->
                              {inet:ip_address(), tcp_port()} |
                              {undefined, tcp_port()}

returns the local ip address and port

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