Sockets
| TCP client and server | |
| UDP datagrams | |
| GenTCP wrapper | |
| Closing a connection |
TCP client and server
GenTCP simplifies TCP sockets. The listen function starts a server, and the connect function opens a client. Both return a socket object that you use with send and recv.
1> {ok, ListenPid} = gen_tcp:listen(4567, [binary, {packet, 1}]).
ok, #Port<0.0.0.0.4567
{ok, Socket} = gen_tcp:connect("127.0.0.1", 4567, [binary, packet, 1]).
ok
Next: HTTP clients
Article author: Arthur Isaev