GSMLG.Socket (GSMLG.Socket v0.1.0)

Link to this section Summary

Link to this section Types

Link to this section Functions

See GSMLG.Socket.Protocol.accept/1.

Link to this function

accept(self, options)

See GSMLG.Socket.Protocol.accept/2.

Link to this function

accept!(self, options)

See GSMLG.Socket.Protocol.active/1.

Link to this function

active(self, mode)

See GSMLG.Socket.Protocol.active/2.

Link to this function

active!(self, mode)

See GSMLG.Socket.Protocol.close/1.

@spec connect(String.t() | URI.t()) :: {:ok, t()} | {:error, any()}

Create a socket connecting to somewhere using an URI.

supported-uris

Supported URIs

  • tcp://host:port for GSMLG.Socket.TCP
  • ssl://host:port for GSMLG.Socket.SSL
  • ws://host:port/path for GSMLG.Socket.Web (using GSMLG.Socket.TCP)
  • wss://host:port/path for GSMLG.Socket.Web (using GSMLG.Socket.SSL)
  • udp://host:port for GSMLG.Socket:UDP

example

Example

{ :ok, client } = GSMLG.Socket.connect "tcp://google.com:80"
client.send "GET / HTTP/1.1\r\n"
client.recv
@spec connect!(String.t() | URI.t()) :: t() | no_return()

Create a socket connecting to somewhere using an URI, raising if an error occurs, see connect.

Link to this function

equal?(self, other)

See GSMLG.Socket.Protocol.equal?/2.

@spec listen(String.t() | URI.t()) :: {:ok, t()} | {:error, any()}

Create a socket listening somewhere using an URI.

supported-uris

Supported URIs

If host is * it will be converted to 0.0.0.0.

  • tcp://host:port for GSMLG.Socket.TCP
  • ssl://host:port for GSMLG.Socket.SSL
  • ws://host:port/path for GSMLG.Socket.Web (using GSMLG.Socket.TCP)
  • wss://host:port/path for GSMLG.Socket.Web (using GSMLG.Socket.SSL)
  • udp://host:port for GSMLG.Socket:UDP

example

Example

{ :ok, server } = GSMLG.Socket.listen "tcp://*:1337"
client = server |> GSMLG.Socket.accept!(packet: :line)
client |> GSMLG.Socket.Stream.send(client.recv)
client |> GSMLG.Socket.Stream.close
@spec listen!(String.t() | URI.t()) :: t() | no_return()

Create a socket listening somewhere using an URI, raising if an error occurs, see listen.

See GSMLG.Socket.Protocol.local/1.

Link to this function

options(self, opts)

See GSMLG.Socket.Protocol.options/2.

Link to this function

options!(self, opts)

Link to this function

packet(self, type)

See GSMLG.Socket.Protocol.packet/2.

Link to this function

packet!(self, type)

See GSMLG.Socket.Protocol.passive/1.

Link to this function

process(self, pid)

See GSMLG.Socket.Protocol.process/2.

Link to this function

process!(self, pid)

See GSMLG.Socket.Protocol.remote/1.