Socket library.
This library contains functions which create TCP/IP socket servers and clients.
asynch_accept/2 | Used by server_loop/8 to handle the listen socket. |
client/4 | Waits for a server to become available, connects to it, and returns a socket. |
client/6 | Implements a generic socket client. |
couple/1 | Equivalent to couple(socket(), self()). |
couple/2 | Couples a socket to a process. |
coupler/2 | Used by couple/2 to achieve socket/process coupling. |
server/5 | Equivalent to server(Mod, Func, Args, Port, Opts, 1000000000). |
server/6 | Implements a generic TCP/IP socket server. |
server_setup/7 | Used by server/6 to handle the listen socket. |
asynch_accept(Parent::pid(), LSock::listen_socket()) -> never_returns
Used by server_loop/8
to handle the listen socket.
This function waits for a connection using gen_tcp:accept/1
and notifies the parent process which spawned it when a connection happens,
allowing the parent to process other messages in the meantime.
This function should not be called directly by users of this module.
client(Host::address(), Port::port(), Options::options(), Interval::interval()) -> {ok, socket()} | {error, Reason}
Waits for a server to become available, connects to it, and
returns a socket. This function tries to contact the server repeatedly,
every Interval
milliseconds.
client(Module::module(), Function::function(), Args::args(), Address::address(), Port::port(), Options::options()) -> pid() | {error, Reason}
Implements a generic socket client.
Connects to a socket with the given options on the given
port and spawns Module:Function(Socket, Args...)
to handle
the connection.
couple(Socket::socket()) -> pid()
Equivalent to couple(socket(), self()).
couple(Socket::socket(), Pid::pid()) -> pid()
Couples a socket to a process. Messages can be sent to the process and will be picked up on the other end of the socket (which is also presumably coupled similarly.) Likewise, messages sent from the other end of the connection will be delivered to the owner. In essence this allows two Erlang sessions to communicate with each other in the same manner as communicating with any other process (that is, by sending Erlang messages,) without the nodes necessarily even being in the same distribution, or indeed any distribution at all. The socket should be opened in binary mode.
coupler(Socket::socket(), Owner::pid()) -> ok
Used by couple/2 to achieve socket/process coupling. Translates tcp messages to Erlang terms and vice versa. This function should not be called directly by users of this module.
server(Mod::atom(), Func::atom(), Args::[term()], Port::integer(), Opts::[option()]) -> pid() | {error, reason()}
Equivalent to server(Mod, Func, Args, Port, Opts, 1000000000).
server(Mod::atom(), Func::atom(), Args::[term()], Port::integer(), Opts::[option()], MaxCon::integer()) -> pid() | {error, reason()}
Implements a generic TCP/IP socket server.
Opens a socket with the given options on the given
port and spawns Module:Function(Socket, Args...)
to handle
each incoming connection, up to the specified maximum number of connections.
server_setup(Mod::atom(), Func::atom(), Args::[term()], LSock::listen_socket(), Port::integer(), Opts::[option()], MaxCon::integer()) -> never_returns
Used by server/6
to handle the listen socket.
This function should not be called directly by users of this module.
Generated by EDoc, Feb 18 2008, 06:48:05.