Mailroom v0.1.1 Mailroom.Socket View Source
Abstracts 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)
Link to this section Summary
Functions
Closes the connection
Connect to a TCP server
on port
Receive a line from the socket
Send data on a socket
Link to this section Types
Link to this section Functions
Link to this function
close(socket)
View Source
close(socket)
View Source
close(t()) :: :ok
close(t()) :: :ok
Closes the connection
Examples
:ok = Mailroom.Socket.close(socket)
Link to this function
connect(server, port, opts \\ []) View Source
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)
Link to this function
recv(socket) View Source
Receive a line from the socket
Examples
{:ok, line} = Mailroom.Socket.recv(socket)
Link to this function
send(socket, data) View Source
Send data on a socket
Examples
:ok = Mailroom.Socket.send(socket)
Link to this function