---
name: "megaco_tcp"
section: "3erl"
platform: "linux"
package: "erlang-manpages"
version: "1:25.2.3+dfsg-1+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/megaco_tcp"
---

# megaco\_tcp(3erl)

Interface module to TPKT transport protocol for Megaco/H.248.

## NAME

megaco\_tcp - Interface module to TPKT transport protocol for Megaco/H.248.

## DESCRIPTION

This module contains the public interface to the TPKT (TCP/IP) version transport protocol for Megaco/H.248.

## EXPORTS

**start\_transport() -\> {ok, TransportRef}**\

Types:

TransportRef = pid()\

This function is used for starting the TCP/IP transport service. Use exit(TransportRef, Reason) to stop the transport service.

**listen(TransportRef, ListenPortSpecList) -\> ok**\

Types:

TransportRef = pid() \| regname()\
 OptionListPerPort = \[Option\]\
 Option = {port, integer()} \| {options, list()} \| {receive\_handle, term()} \| {inet\_backend, default \| inet \| socket}\

This function is used for starting new TPKT listening socket for TCP/IP. The option list contains the socket definitions.

**connect(TransportRef, OptionList) -\> {ok, Handle, ControlPid} \| {error, Reason}**\

Types:

TransportRef = pid() \| regname()\
 OptionList = \[Option\]\
 Option = {host, IpAddr} \| {port, integer()} \| {options, list()} \| {receive\_handle, term()} \| {module, atom()} \| {inet\_backend, default \| inet \| socket}\
 Handle = socket\_handle()\
 ControlPid = pid()\
 Reason = term()\

This function is used to open a TPKT connection.

- ***module*:**

  This option makes it possible for the user to provide their own callback module. The *receive\_message/4* or *process\_received\_message/4* functions of this module is called when a new message is received. Which one is called depends on the size of the message;

  - ***small*:**

    receive\_message

  - ***large*:**

    process\_received\_message

  Default value is *megaco*.

**close(Handle) -\> ok**\

Types:

Handle = socket\_handle()\

This function is used for closing an active TPKT connection.

**socket(Handle) -\> Socket**\

Types:

Handle = socket\_handle()\
 Socket = inet\_socket()\

This function is used to convert a socket\_handle() to a inet\_socket(). inet\_socket() is a plain socket, see the inet module for more info.

**send\_message(Handle, Message) -\> ok**\

Types:

Handle = socket\_handle()\
 Message = binary() \| iolist()\

Sends a message on a connection.

**block(Handle) -\> ok**\

Types:

Handle = socket\_handle()\

Stop receiving incoming messages on the socket.

**unblock(Handle) -\> ok**\

Types:

Handle = socket\_handle()\

Starting to receive incoming messages from the socket again.

**upgrade\_receive\_handle(ControlPid) -\> ok**\

Types:

ControlPid = pid()\

Update the receive handle of the control process (e.g. after having changed protocol version).

**get\_stats() -\> {ok, TotalStats} \| {error, Reason}**\
 **get\_stats(SendHandle) -\> {ok, SendHandleStats} \| {error, Reason}**\
 **get\_stats(SendHandle, Counter) -\> {ok, CounterStats} \| {error, Reason}**\

Types:

TotalStats = \[send\_handle\_stats()\]\
 total\_stats() = {send\_handle(), \[stats()\]}\
 SendHandle = send\_handle()\
 SendHandleStats = \[stats()\]\
 Counter = tcp\_stats\_counter()\
 CounterStats = integer()\
 stats() = {tcp\_stats\_counter(), integer()}\
 tcp\_stats\_counter() = medGwyGatewayNumInMessages \| medGwyGatewayNumInOctets \| medGwyGatewayNumOutMessages \| medGwyGatewayNumOutOctets \| medGwyGatewayNumErrors\
 Reason = term()\

Retreive the TCP related (SNMP) statistics counters.

**reset\_stats() -\> void()**\
 **reset\_stats(SendHandle) -\> void()**\

Types:

SendHandle = send\_handle()\

Reset all TCP related (SNMP) statistics counters.
