Module ce_socket

Socket library.

Description

Socket library.

This library contains functions which create TCP/IP socket servers and clients.

Function Index

asynch_accept/2Used by server_loop/8 to handle the listen socket.
client/4Waits for a server to become available, connects to it, and returns a socket.
client/6Implements a generic socket client.
couple/1Equivalent to couple(socket(), self()).
couple/2Couples a socket to a process.
coupler/2Used by couple/2 to achieve socket/process coupling.
server/5Equivalent to server(Mod, Func, Args, Port, Opts, 1000000000).
server/6Implements a generic TCP/IP socket server.
server_setup/7Used by server/6 to handle the listen socket.

Function Details

asynch_accept/2

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/4

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/6

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/1

couple(Socket::socket()) -> pid()

Equivalent to couple(socket(), self()).

couple/2

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/2

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/5

server(Mod::atom(), Func::atom(), Args::[term()], Port::integer(), Opts::[option()]) -> pid() | {error, reason()}

Equivalent to server(Mod, Func, Args, Port, Opts, 1000000000).

server/6

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/7

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, Dec 25 2007, 02:37:49.