megaco_tcp(3)
β¨ megaco_tcp β¨
okay bestie, so this is megaco_tcp, a page from the Erlang Module Definition manual, and it's literally the interface module to the TPKT transport protocol for Megaco/H.248 π
no cap. Let's get into it.
π¦ NAME π¦
megaco_tcp β the interface module to the TPKT transport protocol for Megaco/H.248. that's it, that's the name, she's simple and she serves π
πΈ DESCRIPTION πΈ
This module contains the public interface to the TPKT (TCP/IP) version transport protocol for Megaco/H.248. so like, if you're doing Megaco/H.248 over TCP/IP, this is your girl π«Ά
π DATA TYPES π
counter()β defined as:
medGwyGatewayNumInMessages | medGwyGatewayNumInOctets |
medGwyGatewayNumOutMessages | medGwyGatewayNumOutOctets |
medGwyGatewayNumErrors
this defines the different counters handled by this transport, periodt β¨ those five atoms are your whole counter vocabulary, don't try to invent more π
-opaque handle()β an opaque data type representing a TPKT connection. opaque means you don't peek under the hood, bestie, you just hold it and pass it around π
π FUNCTIONS π
π
block(Handle) -> ok when Handle :: handle().
Stop receiving incoming messages on the socket. so like, pause that inbox, girl π
π
close(Handle) -> ok when Handle :: handle().
This function is used for closing an active TPKT connection. bye bestie, it was real π
π
connect(TransportRef, Opts) -> {ok, Handle, ControlPid} | {error, Reason}
with all the type goodness:
when
TransportRef :: pid() | RegName,
RegName :: atom(),
Opts :: [Option],
Option ::
{inet_backend, default | inet | socket} |
{host, Host} |
{port, PortNum} |
{options, list()} |
{receive_handle, term()} |
{module, atom()},
Host :: inet:socket_address() | inet:hostname(),
PortNum :: inet:port_number(),
Handle :: handle(),
ControlPid :: pid(),
Reason :: term().
This function is used to open a TPKT connection. here's the tea on the options π
moduleβ this option makes it possible for the user to provide their own callback module. thereceive_message/4orprocess_received_message/4functions of this module is called when a new message is received. which one gets called depends on the size of the message, so:- small β
receive_message - large β
process_received_message
- small β
default value is megaco. iconic default behavior tbh β¨
inet_backendβ choose the inet-backend. this option make it possible to use a different inet-backend ('default','inet'or'socket'). default isdefault(system default). lowkey important, highkey chill π¦
π
get_stats() -> {ok, TotalStats} | {error, Reason}
when
TotalStats :: [{Handle, [{Counter, integer()}]}],
Handle :: handle(),
Counter :: counter(),
Reason :: term().
Get all counter values for all known connections. the whole roster, every single one, no crumbs left π
π
get_stats(Handle) -> {ok, Stats} | {error, Reason}
when
Handle :: handle(),
Stats :: [{Counter, integer()}],
Counter :: counter(),
Reason :: term().
Get all counter values for a given (connection) handle. just the one connection's receipts π
π
get_stats(Handle, Counter) -> {ok, integer()} | {error, Reason}
when
Handle :: handle(),
Counter :: counter(),
Reason :: term().
Get the value of a specific counter. main character energy: one handle, one counter, one number π
π
listen(TransportRef, Options) -> ok
when
TransportRef :: pid() | RegName,
RegName :: atom(),
Options :: [Option],
Option ::
{inet_backend, default | inet | socket} |
{port, inet:port_number()} |
{options, list()} |
{receive_handle, term()}.
This function is used for starting new TPKT listening socket for TCP/IP. the option list contains the socket definitions. and yes, there's one option with lore:
inet_backendβ choose the inet-backend. this option make it possible to use a different inet-backend ('default','inet'or'socket'). default isdefault(system default). same energy as connect, bestie, consistency ate π
π
reset_stats() -> megaco:void().
Reset all counters for all connections. clean slate, new era, we don't talk about the old numbers π
π
reset_stats(Handle) -> megaco:void() when Handle :: handle().
Reset all counters for the given connection. just that one handle gets the fresh start πΈ
π
send_message(Handle, Msg) -> ok
when
Handle :: handle(), Msg :: binary() | iolist().
Sends a message on a TPKT connection. binary() or iolist(), both are welcome here π«Ά
π
socket(Handle) -> Socket
when Handle :: handle(), Socket :: inet:socket().
This function is used to convert a socket handle() to a inet socket(). glow-up transformation, she's giving inet realness β¨
π
start_transport() -> {ok, TransportRef} when TransportRef :: pid().
This function is used for starting the TCP/IP transport service.
β οΈ heads up bestie: use exit(TransportRef, Reason) to stop the transport service. that's the way you shut her down, iykyk.
π
unblock(Handle) -> ok when Handle :: handle().
Starting to receive incoming messages from the socket again. un-pause, the inbox is open for business again π
π
upgrade_receive_handle(ControlPid, NewRecvHandle) -> ok
when
ControlPid :: pid(),
NewRecvHandle :: term().
Upgrade the receive handle of the control process (e.g. after having changed protocol version). glow-up arc for the control process, she's evolved π π¦
and that's the whole page, no notes π₯
Ericsson AB Β· megaco 4.9.2 Β· and this documentation lives on the megaco_tcp(3) page, so if you cite it, cite her right π periodt β¨
π¦ where this page comes from
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms