xturn_sockets v0.1.0 Xirsys.Sockets.Socket View Source

Socket protocol helpers

Link to this section Summary

Functions

Returns the client message hooks from config

Closes a socket of any type.s

Performs the SSL/TLS/DTLS server-side handshake if a secure socket, otherwise simply accepts an incoming connection request on a listening socket.

Opens a new port for UDP TURN transport

Returns the peer message hooks from config

Returns the peer address and port number for a socket.

With new data, see if we can process a message on the buffer

Sends a message over an open udp socket port

Sends data to client hooks

Sends data to peer hooks

Returns the server ip from config for packet use

Returns the servers local ip from the config

Apply specific socket option for STUN connection

Sets one or more options for a socket.

Returns the local address and port number for a socket.

Link to this section Types

Link to this type

t()

View Source
t() :: {type :: :udp | :tcp | :dtls | :tls, sock :: port()}

Link to this section Functions

Link to this function

client_hooks()

View Source
client_hooks() :: list()

Returns the client message hooks from config

Link to this function

close(sock, reason \\ "")

View Source
close(Xirsys.Sockets.Socket.t() | any(), any()) :: :ok

Closes a socket of any type.s

Link to this function

handshake(socket)

View Source
handshake(%Xirsys.Sockets.Socket{sock: term(), type: term()}) ::
  {:ok, %Xirsys.Sockets.Socket{sock: term(), type: term()}} | {:error, any()}

Performs the SSL/TLS/DTLS server-side handshake if a secure socket, otherwise simply accepts an incoming connection request on a listening socket.

Link to this function

open_turn_port(sip, policy, opts)

View Source
open_turn_port(tuple(), atom(), list()) ::
  {:ok, Xirsys.Sockets.Socket.t()} | {:error, atom()}

Opens a new port for UDP TURN transport

Link to this function

peer_hooks()

View Source
peer_hooks() :: list()

Returns the peer message hooks from config

Link to this function

peername(socket)

View Source
peername(any()) ::
  {:ok, {tuple(), integer()}}
  | {:local, binary()}
  | {:unspec, <<_::0>>}
  | {:undefined, any()}
  | {:error, term()}

Returns the peer address and port number for a socket.

Link to this function

process_buffer(socket, data, buffer, addr, callback)

View Source
process_buffer(any(), binary(), binary(), tuple(), function()) :: binary()

With new data, see if we can process a message on the buffer

Link to this function

send(socket, msg, ip \\ nil, port \\ nil)

View Source
send(
  %Xirsys.Sockets.Socket{sock: term(), type: term()},
  binary(),
  tuple() | nil,
  integer() | nil
) :: :ok | {:error, term()} | no_return()

Sends a message over an open udp socket port

Link to this function

send_to_client_hooks(data)

View Source

Sends data to client hooks

Link to this function

send_to_peer_hooks(data)

View Source

Sends data to peer hooks

Link to this function

server_ip()

View Source
server_ip() :: tuple()

Returns the server ip from config for packet use

Link to this function

server_local_ip()

View Source
server_local_ip() :: tuple()

Returns the servers local ip from the config

Link to this function

set_sockopt(list_sock, cli_socket)

View Source
set_sockopt(
  %Xirsys.Sockets.Socket{sock: term(), type: term()},
  %Xirsys.Sockets.Socket{sock: term(), type: term()}
) :: :ok

Apply specific socket option for STUN connection

Link to this function

setopts(socket, opts \\ [{:active, :once}, :binary])

View Source
setopts(port() | %Xirsys.Sockets.Socket{sock: term(), type: term()}, list()) ::
  :ok | {:error, term()}

Sets one or more options for a socket.

Link to this function

sockname(socket)

View Source
sockname(any()) ::
  {:ok, {tuple(), integer()}}
  | {:local, binary()}
  | {:unspec, <<_::0>>}
  | {:undefined, any()}
  | {:error, term()}

Returns the local address and port number for a socket.