Mailroom.Socket (Mailroom v0.6.0)
View SourceAbstracts away working with normal sockets or SSL sockets.
Examples
{:ok, socket} = Mailroom.Socket.connect("localhost", 110)
{:ok, ssl_socket} = Mailroom.Socket.connect("localhost", 110, ssl: true)
Mailroom.Socket.send(socket, "Hello World")
Mailroom.Socket.send(ssl_socket, "Hello World")
Mailroom.Socket.close(socket)
Mailroom.Socket.close(ssl_socket)
Summary
Functions
Closes the connection
Connect to a TCP server
on port
Receive a line from the socket
Send data on a socket
Types
Functions
@spec close(t()) :: :ok
Closes the connection
Examples
:ok = Mailroom.Socket.close(socket)
Connect to a TCP server
on port
The following options are available:
ssl
- defaultfalse
, connect via SSL or nottimeout
- default15000
, sets the socket connect and receive timeoutdebug
- defaultfalse
, if true, will print out connection communication
Examples
{:ok, socket} = Mailroom.Socket.connect("localhost", 110, ssl: true)
Receive a line from the socket
Examples
{:ok, line} = Mailroom.Socket.recv(socket)
Send data on a socket
Examples
:ok = Mailroom.Socket.send(socket)