gen_tcp
gen_tcp
Module
gen_tcp
Module summary
Interface to TCP/IP sockets.
Description
This module provides functions for communicating with sockets using the TCP/IP protocol.
The following code fragment is a simple example of a client connecting to a server at port 5678, transferring a binary, and closing the connection:
client() -> SomeHostInNet = "localhost", % to make it runnable on one machine {ok, Sock} = gen_tcp:connect(SomeHostInNet, 5678, [binary, {packet, 0}]), ok = gen_tcp:send(Sock, "Some Data"), ok = gen_tcp:close(Sock).
At the other end, a server is listening on port 5678, accepts the connection, and receives the binary:
server() -> {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, 0}, {active, fal