This module enables C-programs to communicate with Erlang nodes, using the Erlang distribution over TCP/IP.
A C-node appears to Erlang as a hidden node.
That is, Erlang processes that know the name of the
C-node can communicate with it in a normal manner, but
the node name is not shown in the listing provided by
The environment variable
Most functions appear in a version with the suffix
Clearly the time-outs are for implementing fault tolerance,
not to keep hard real-time promises. The
A time-out value of
As with all other functions starting with
In all other senses, the
By default
All callbacks in the
The
The
Flags informing
If set, the
If not set,
More flags may be introduced in the future.
Create a socket and a context for the socket.
On success it should set
During the lifetime of a socket, the pointer
This callback is mandatory.
Close the socket identified by
This callback is mandatory.
Bind the socket identified by
The
This callback is mandatory.
Accept connections on the listen socket identified by
When a connection is accepted, a new context for the accepted
connection should be created and
If the
During the lifetime of a socket, the pointer
This callback is mandatory.
Connect the socket identified by
When called
If the
This callback is mandatory.
Write data on the connected socket identified by
If the
This callback is optional. Set the
Write data on the connected socket identified by
When called
If the
This callback is mandatory.
Read data on the connected socket identified by
If the
This callback is mandatory.
Inform about handshake packet header size to use during the Erlang distribution handshake.
On success,
This callback is mandatory.
Called when a locally started handshake has completed successfully.
This callback is optional. Set the
Called when a remotely started handshake has completed successfully.
This callback is optional. Set the
Inform about file descriptor used by the socket which is identified
by
During the lifetime of a socket, the file descriptor
has to remain the same. That is, repeated calls to this
callback with the same context
The file descriptor has to be a real file descriptor.
That is, no other operation should be able to get the same file
descriptor until it has been released by the
This callback is mandatory.
Convenience functions for some common name lookup functions.
Used by a server process to accept a connection from a client process.
On success,
Equivalent to
Closes a previously opened connection or listen socket.
Sets up a connection to an Erlang node.
These functions return an open file descriptor on success, or
a negative value indicating that an error occurred. In the latter
case they set
Also,
Example:
Initializes the
A C-node acting as a server is assigned a creation
number when it calls
A connection is closed by simply closing the socket. For information about how to close the socket gracefully (when there are outgoing packets before close), see the relevant system documentation.
These functions return a negative value indicating that an error occurred.
Example 1:
Example 2:
Equivalent to
Used to set tracing on the distribution. The levels are different
verbosity levels. A higher level means more information. See also
section
These functions are not thread safe.
Used by a server process to setup a listen socket which later can be used for accepting connections from client processes.
On success, a file descriptor is returned which can be used in a call to
Used by a server process to register
with the local name server EPMD, thereby allowing
other processes to send messages by using the registered name.
Before calling either of these functions, the process should
have called
To unregister with EPMD, simply close the returned descriptor. Do
not use
On success, the function returns a descriptor connecting the
calling process to EPMD. On failure,
Also,
Equivalent to
Receives a message consisting of a sequence of bytes in the Erlang external format.
If a tick occurs, that is, the Erlang node on the
other end of the connection has polled this node to see if it
is still alive, the function returns
On success, the message is placed in the specified buffer
and the function returns the number of bytes actually read. On
failure, the function returns
This function is retained for compatibility with code generated by the interface compiler and with code following examples in the same application.
In essence, the function performs the same operation as
Returns either
It is recommended to use
Equivalent to
Receives a message to the buffer in
On success, the functions return
Indicates that an ordinary send operation has occurred.
A registered send operation occurred.
Indicates a broken link.
The return value is the same as for
Equivalent to
Equivalent to
Sends an Erlang term to a registered process.
Returns
Example:
Send the atom "ok" to the process "worker":
Equivalent to
Supports calling Erlang functions on remote nodes.
Example:
Check to see if an Erlang process is alive:
Retrieves the pid of the C-node. Every C-node
has a (pseudo) pid used in
Sends an Erlang term to a process.
Returns
Works exactly as
Equivalent to
This function is retained for compatibility with code generated by the interface compiler and with code following examples in the same application.
The function works as
A suitable
num = fd;
]]>
Equivalent to
Equivalent to
Can be used to retrieve information about
the C-node. These values are initially set with
These function simply fetch the appropriate field from the
Can be called by a process to unregister a
specified node from EPMD on the local host. This is, however, usually
not allowed, unless EPMD was started with flag
To unregister a node you have published, you should
close the descriptor that was returned by
This function is deprecated and will be removed in a future release.
If the node was successfully unregistered from EPMD, the
function returns
Equivalent to
If a connection attempt fails, the following can be checked:
The connection attempt can be traced by setting a trace level by either
using