From 3d70cee4034e4da37d125679345aa2a10c58cb34 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= The application resource file should be called
- It must contain one single Erlang term, which is called an
+ The application resource file is to be called
+ The file must contain a single Erlang term, which is called an
application specification: For the application controller, all keys are optional.
The respective default values are used for any omitted keys. The functions in The
{application, Application,
@@ -80,19 +80,26 @@ Env [{Par,Val}] []
Start {Module,StartArgs} []
Phases [{Phase,PhaseArgs}] undefined
RTDeps [ApplicationVersion] []
- Module = Name = App = Par = Phase = atom()
- Val = StartArgs = PhaseArgs = term()
- ApplicationVersion = string()
-
The other keys are ignored by
The version of the application.
+Version of the application.
Deprecated - will be ignored
-
- The maximum number of processes allowed in the application.
Deprecated - is ignored
+Maximum number of processes allowed in the application.
The maximum time in milliseconds that the application is - allowed to run. After the specified time the application will - automatically terminate.
+Maximum time, in milliseconds, that the application is + allowed to run. After the specified time, the application + terminates automatically.
All applications which are included by this application. - When this application is started, all included application - will automatically be loaded, but not started, by - the application controller. It is assumed that the topmost +
All applications included by this application. + When this application is started, all included applications + are loaded automatically, but not started, by + the application controller. It is assumed that the top-most supervisor of the included application is started by a supervisor of this application.
All applications which must be started before this +
All applications that must be started before this
application is allowed to be started.
Specifies the application callback module and a start
- argument, see
The
Specifies the application callback module and a start argument, see
+
Key
A list of start phases and corresponding start arguments for
the application. If this key is present, the application
- master will - in addition to the usual call to
-
Start phases may be used to synchronize startup of an
+ start phase defined by key
Start phases can be used to synchronize startup of an
application and its included applications. In this case,
- the
{mod, {application_starter,[Module,StartArgs]}}
- The application master will then call
The application master then calls
This implies that for an included application, the set of start phases must be a subset of the set of phases defined - for the primary application. Refer to OTP Design Principles for more information.
+ for the primary application. For more information, see +A list of application versions that the application
- depends on. An example of such an application version is
-
Some dependencies might only be required in specific runtime - scenarios. In the case such optional dependencies exist, these are - specified and documented in the corresponding "App" documentation - of the specific application.
-The
All runtime dependencies specified in OTP applications - during the OTP 17 release may not be completely correct. This - is actively being worked on. Declared runtime dependencies in OTP - applications are expected to be correct in OTP 18.
A list of application versions that the application
+ depends on. An example of such an application version is
+
Notice that the application version + specifies a source code version. One more, indirect, + requirement is that the installed binary application of + the specified version is built so that it is + compatible with the rest of the system.
+Some dependencies can only be required in specific runtime + scenarios. When such optional dependencies exist, these are + specified and documented in the corresponding "App" documentation + of the specific application.
+The
All runtime dependencies specified in OTP applications + during the OTP 17 release may not be completely correct. This + is actively being worked on. Declared runtime dependencies in OTP + applications are expected to be correct in OTP 18.
In OTP, application denotes a component implementing some specific functionality, that can be started and stopped as a - unit, and which can be re-used in other systems as well. This - module interfaces the application controller, a process - started at every Erlang runtime system, and contains functions - for controlling applications (for example starting and stopping + unit, and that can be reused in other systems. This + module interacts with application controller, a process + started at every Erlang runtime system. This module contains functions + for controlling applications (for example, starting and stopping applications), and functions to access information about - applications (for example configuration parameters).
-An application is defined by an application specification. The specification is normally located in an
- application resource file called
An application is defined by an application specification.
+ The specification is normally located in an
+ application resource file named
This module can also be viewed as a behaviour for an application implemented according to the OTP design principles as a supervision tree. The definition of how to start and stop - the tree should be located in an application callback module exporting a pre-defined set of functions.
-Refer to
For details about applications and behaviours, see
+
Equivalent to calling
+
Returns
The function reports
If an error occurs, the applications started by the function are stopped + to bring the set of running applications back to its initial state.
+Equivalent to
+
Returns the configuration parameters and their values for
Returns the application specification keys and their values
for Returns the name of the application to which the process
Returns the value of the configuration parameter Returns the value of configuration parameter If the specified application is not loaded, or
- the configuration parameter does not exist, or if the process
- executing the call does not belong to any application,
- the function returns Returns Works like Works like Returns the value of the application specification key
If the specified application is not loaded, or
- the specification key does not exist, or if the process
- executing the call does not belong to any application,
- the function returns Returns Loads the application specification for an application into
- the application controller. It will also load the application
- specifications for any included applications. Note that
- the function does not load the actual Erlang object code. The application can be given by its name The application can be specified by its name The application specification can also be given directly as a
- tuple The application specification can also be specified directly as a
+ tuple If Example: This means that the application should preferably be started
+ This means that the application is preferably to be started
at If
+
+
+
Nodes = [cp1@cave, {cp2@cave, cp3@cave}]
-
Returns a list with information about the applications which
- have been loaded using
Returns a list with information about the applications, and included
+ applications, which are loaded using
Changes the permission for
If the permission of a loaded, but not started, application
- is set to
If the permission of a running application is set to
-
If the application is distributed, setting the permission to
The function does not return until the application is
- started, stopped or successfully moved to another node.
- However, in some cases where permission is set to
By default, all applications are loaded with permission
-
Sets the value of the configuration parameter
Sets the value of configuration parameter
If
The
Option
Use this function only if you know what you are doing, - that is, on your own applications. It is very application - and configuration parameter dependent when and how often - the value is read by the application, and careless use - of this function may put the application in a - weird, inconsistent, and malfunctioning state.
+Use this function only if you know what you are doing, + that is, on your own applications. It is very + application-dependent and + configuration parameter-dependent when and how often + the value is read by the application. Careless use + of this function can put the application in a + weird, inconsistent, and malfunctioning state.
Equivalent to
Equivalent to calling
Starts
The application controller checks the value of
the application specification key
The application controller then creates an application master for the application. The application master is +
The application controller then creates an application master
+ for the application. The application master is
the group leader of all the processes in the application.
The application master starts the application by calling
the application callback function
The
Argument
Note that it is always possible to stop an application +
Notice that an application can always be stopped
explicitly by calling
Note also that the transient type is of little practical use, - since when a supervision tree terminates, the reason is set to + the application, no other applications are affected.
+Notice also that the transient type is of little practical use,
+ because when a supervision tree terminates, the reason is set to
This function is intended to be called by a process belonging
- to an application, when the application is being started, to
- determine the start type which is either
See
For a description of
If the process executing the call does not belong to any
application, the function returns
Stops
Last, the application master itself terminates. Note that all - processes with the application master as group leader, i.e. +
Last, the application master terminates. Notice that all + processes with the application master as group leader, that is, processes spawned from a process belonging to the application, - thus are terminated as well.
+ are also terminated.When stopped, the application is still loaded.
-In order to stop a distributed application,
To stop a distributed application,
Performs a takeover of the distributed application +
Takes over the distributed application
Thus two instances of the application will run simultaneously - during the takeover, which makes it possible to transfer data - from the old to the new instance. If this is not acceptable - behavior, parts of the old instance may be shut down when - the new instance is started. Note that the application may - not be stopped entirely however, at least the top supervisor +
Thus, two instances of the application run simultaneously + during the takeover, so that data can be transferred + from the old to the new instance. If this is not an acceptable + behavior, parts of the old instance can be shut down when + the new instance is started. However, the application cannot + be stopped entirely, at least the top supervisor must remain alive.
-See
For a description of
Unloads the application specification for
Removes the configuration parameter
Use this function only if you know what you are doing, - that is, on your own applications. It is very application - and configuration parameter dependent when and how often - the value is read by the application, and careless use - of this function may put the application in a - weird, inconsistent, and malfunctioning state.
+ (seeUse this function only if you know what you are doing, + that is, on your own applications. It is very + application-dependent and configuration + parameter-dependent when and how often + the value is read by the application. Careless use + of this function can put the application in a + weird, inconsistent, and malfunctioning state.
Returns a list with information about the applications which +
Returns a list with information about the applications that
are currently running.
The following functions should be exported from an +
The following functions are to be exported from an
This function is called whenever an application is started
- using
The function should return
The function is to return
This function is used to start an application with included - applications, when there is a need for synchronization between +
Starts an application with included + applications, when synchronization is needed between processes in the different applications during startup.
-The start phases is defined by the application specification +
The start phases are defined by the application specification
key
The function is called for each start phase (as defined for the primary application) for the primary application and all included applications, for which the start phase is defined.
-See
For a description of
The function is optional. If it is not defined, the processes
- will be terminated and then
This function is called whenever an application has stopped.
It is intended to be the opposite of
This function is called by an application after a code - replacement, if there are any changes to the configuration - parameters.
-This module is deprecated. For a description of the Magic
Cookie system, refer to
@@ -41,61 +41,61 @@
Returns Use Use
-
Use
-
Returns
Use
Equivalent to
-
Sets the magic cookie of
Sets the magic cookie of
This module contains the interface to the Erlang code server, which deals with the loading of compiled code into a running Erlang runtime system.
-The runtime system can be started in either embedded or
- interactive mode. Which one is decided by the command
- line flag
The runtime system can be started in embedded or
+ interactive mode. Which one is decided by command-line
+ flag
% erl -mode interactive-
Default mode is
The modes are as follows:
In embedded mode, all code is loaded during system start-up +
In embedded mode, all code is loaded during system startup according to the boot script. (Code can also be loaded later by explicitly ordering the code server to do so).
In interactive mode, only some code is loaded during system - startup-up, basically the modules needed by the runtime - system itself. Other code is dynamically loaded when first +
In interactive mode, which is default, only some code is loaded + during system startup, basically the modules needed by the runtime + system. Other code is dynamically loaded when first referenced. When a call to a function in a certain module is made, and the module is not loaded, the code server searches for and tries to load the module.
To prevent accidentally reloading modules affecting the Erlang
- runtime system itself, the
To prevent accidentally reloading of modules affecting the Erlang
+ runtime system, directories
In interactive mode, the code server maintains a search path -- - usually called the code path -- consisting of a list of +
In interactive mode, the code server maintains a search path, + usually called the code path, consisting of a list of directories, which it searches sequentially when trying to load a module.
Initially, the code path consists of the current working
- directory and all Erlang object code directories under the library
+ directory and all Erlang object code directories under library
directory
The environment variable
Environment variable
All application directories found in the additional directories - will appear before the standard OTP applications, except for the - Kernel and STDLIB applications, which will be placed before any - additional applications. In other words, modules found in any - of the additional library directories will override modules with - the same name in OTP, except for modules in Kernel and - STDLIB.
-The environment variable
Environment variable
Example: On an Unix-like system,
Example:
+On a Unix-like system,
+/usr/local/jungerl:/home/some_user/my_erlang_lib
+ On Windows, use semi-colon as separator.
The support for loading of code from archive files is
- experimental. The sole purpose of releasing it before it is ready
+ The support for loading code from archive files is
+ experimental. The purpose of releasing it before it is ready
is to obtain early feedback. The file format, semantics,
- interfaces etc. may be changed in a future release. The function
-
In the current implementation, Erlang archives are
The Erlang archives are
Erlang archive files may contain entire Erlang applications or +
Erlang archive files can contain entire Erlang applications or
parts of applications. The structure in an archive file is the
- same as the directory structure for an application. If you for
- example would create an archive of
An archive file for an application may for example be +
An archive file for an application can, for example, be created like this:
- zip:create("mnesia-4.4.7.ez",
- ["mnesia-4.4.7"],
- [{cwd, code:lib_dir()},
- {compress, all},
- {uncompress,[".beam",".app"]}]).
-
- Any file in the archive may be compressed, but in order to - speed up the access of frequently read files, it may be a good +zip:create("mnesia-4.4.7.ez", + ["mnesia-4.4.7"], + [{cwd, code:lib_dir()}, + {compress, all}, + {uncompress,[".beam",".app"]}]). + +
Any file in the archive can be compressed, but to
+ speed up the access of frequently read files, it can be a good
idea to store
Normally the top directory of an application is located either
- in the library directory
Normally the top directory of an application is located
+ in library directory
The code server uses the module
The code server uses module
An application archive file and a regular application directory
- may coexist. This may be useful when there is a need of having
+ can coexist. This can be useful when it is needed to have
parts of the application as regular files. A typical case is the
-
At the time point when a directory is added to the code path as - well as when the entire code path is (re)set, the code server - will decide which subdirectories in an application that shall be - read from the archive and which that shall be read as regular +
When a directory is added to the code path and
+ when the entire code path is (re)set, the code server
+ decides which subdirectories in an application that are to be
+ read from the archive and which that are to be read as regular
files. If directories are added or removed afterwards, the file
- access may fail if the code path is not updated (possibly to the
- same path as before in order to trigger the directory resolution
- update). For each directory on the second level (ebin, priv, src
- etc.) in the application archive, the code server will firstly
- choose the regular directory if it exists and secondly from the
- archive. The function
-
For each directory on the second level in the application archive
+ (
When an
When the choice of directories in the code path is
-
This behavior can be controlled via the command line flag +
This behavior can be controlled through command-line flag
The command line flag
Command-line flag
The code of a module can exists in two variants in a system: +
The code for a module can exist in two variants in a system: current code and old code. When a module is - loaded into the system for the first time, the code of the module + loaded into the system for the first time, the module code becomes 'current' and the global export table is updated with references to all functions exported from the module.
-If then a new instance of the module is loaded (perhaps because - of the correction of an error), then the code of the previous +
If then a new instance of the module is loaded (for example, because of + error correction), the code of the previous instance becomes 'old', and all export entries referring to - the previous instance are removed. After that the new instance is - loaded as if it was loaded for the first time, as described above, - and becomes 'current'.
-Both old and current code for a module are valid, and may even be + the previous instance are removed. After that, the new instance is + loaded as for the first time, and becomes 'current'.
+Both old and current code for a module are valid, and can even be evaluated concurrently. The difference is that exported functions - in old code are unavailable. Hence there is no way to make a - global call to an exported function in old code, but old code may + in old code are unavailable. Hence, a global call cannot be made + to an exported function in old code, but old code can still be evaluated because of processes lingering in it.
-If a third instance of the module is loaded, the code server will - remove (purge) the old code and any processes lingering in it will - be terminated. Then the third instance becomes 'current' and +
If a third instance of the module is loaded, the code server + removes (purges) the old code and any processes lingering in it + are terminated. Then the third instance becomes 'current' and the previously current code becomes 'old'.
For more information about old and current code, and how to
- make a process switch from old to current code, refer to
+ make a process switch from old to current code, see section
+ Compilation and Code Loading in the
Generally, module and application names are atoms, while file and directory +
Module and application names are atoms, while file and directory names are strings. For backward compatibility reasons, some functions accept both strings and atoms, but a future release will probably only allow the arguments that are documented.
-From the R12B release, functions in this module will generally fail with an
- exception if they are passed an incorrect type (for instance, an integer or a tuple
- where an atom was expected). An error tuple will be returned if the type of the argument
- was correct, but there was some other error (for instance, a non-existing directory
- was given to
As from Erlang/OTP R12B, functions in this module generally fail with an
+ exception if they are passed an incorrect type (for example, an integer or a tuple
+ where an atom is expected). An error tuple is returned if the argument type
+ is correct, but there are some other errors (for example, a non-existing directory
+ is specified to
An opaque term holding prepared code.
Sets the code path to the list of directories
Returns
Returns:
+If successful
If any
If the argument is invalid
Returns the code path
+Returns the code path.
Adds
Adds
Returns Adds the directories in Always returns Adds the directories in Always returns Deletes a directory from the code path. The argument can be
an atom Returns
Returns:
+If successful
If the directory is not found
If the argument is invalid
This function replaces an old occurrence of a directory
- named Replaces an old occurrence of a directory
+ named Returns Returns: If successful If If If
Tries to load the Erlang module
Returns
Does the same as
Same as
Tries to to load a module in the same way as
-
Tries to load a module in the same way as
+
This function can be used to load object code on remote
- Erlang nodes. The argument
Returns
Removes the current code for
Returns
Purges the code for
Returns
Returns
Purges the code for
Returns
Returns
Checks if
Normally,
Normally,
Returns a list of tuples
If the module is not loaded, this function searches the code
- path for the first file which contains object code for
-
If the module is loaded, it returns the name of the file + containing the loaded object code.
+If the module is preloaded,
If the module is Cover-compiled,
If the module cannot be found,
Searches the code path for the object code of the module
-
Searches the code path for the object code of module
+
Returns the root directory of Erlang/OTP, which is the directory where it is installed.
+Example:
> code:root_dir(). "/usr/local/otp"@@ -726,10 +748,11 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),
Returns the library directory,
Example:
> code:lib_dir(). "/usr/local/otp/lib"@@ -737,50 +760,49 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),
This function is mainly intended for finding out the path +
Returns the path
for the "library directory", the top directory, for an
application
If there is a regular directory called
If a regular directory called
If the directory refers to a directory in an archive, the
+ archive name is stripped away before the path is returned.
+ For example, if directory
Example:
> code:lib_dir(mnesia). "/usr/local/otp/lib/mnesia-4.2.2"
Returns
For backward compatibility,
For backward compatibility,
Returns the path to a subdirectory directly under the top directory of an application. Normally the subdirectories - resides under the top directory for the application, but when - applications at least partly resides in an archive the - situation is different. Some of the subdirectories may reside - as regular directories while other resides in an archive - file. It is not checked if this directory really exists.
- + reside under the top directory for the application, but when + applications at least partly resides in an archive, the + situation is different. Some of the subdirectories can reside + as regular directories while other reside in an archive + file. It is not checked whether this directory exists. +Example:
> code:lib_dir(megaco, priv). "/usr/local/otp/lib/megaco-3.9.1.1/priv"@@ -791,7 +813,7 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),
Returns the compiler library directory. Equivalent to
Returns the path to the
For backward compatibility,
Returns the object code file extension that corresponds to
- the Erlang machine used, namely
Returns the object code file extension corresponding to
+ the Erlang machine used, namely
This function marks
Returns
Marks
Returns
This function unsticks a directory which has been marked as +
Unsticks a directory that is marked as sticky.
-Returns
Returns
This function returns
Returns
Searches the code path for Searches the entire code space for module names with
+ Searches all directories in the code path for module names with
identical names and writes a report to
This function returns
Returns:
+If
If
If
This function returns an atom describing the code_server's mode:
-
Returns an atom describing the mode of the code server:
+
This information is useful when an external entity (for example,
- an IDE) provides additional code for a running node. If in interactive
- mode, it only needs to add to the code path. If in embedded mode,
- the code has to be loaded with
A configuration file contains values for configuration
parameters for the applications in the system. The
Configuration parameter values in the configuration file will +
Configuration parameter values in the configuration file
override the values in the application resource files (see
-
The value of a configuration parameter is retrieved by calling
The configuration file should be called
The
The configuration file is to be called
File
-[{Application1, [{Par11, Val11}, ..]},
- ..
- {ApplicationN, [{ParN1, ValN1}, ..]}].
- Application name.
Name of a configuration parameter.
Value of a configuration parameter.
When starting Erlang in embedded mode, it is assumed that
exactly one system configuration file is used, named
-
Release handling relies on this assumption. When installing a
new release version, the new
This means that specifying another, or additional,
This means that specifying another
[{Application, [{Par, Val}]} | File].
- When traversing the contents of
Example:
sys.config:
[{myapp,[{par1,val1},{par2,val2}]},
"/home/user/myconfig"].
-
myconfig.config:
[{myapp,[{par2,val3},{par3,val4}]}].
- This will yield the following environment for
This yields the following environment for
[{par1,val1},{par2,val3},{par3,val4}]
- The behaviour if a file specified in
The behavior if a file specified in
Two formats of the log files are supported, the internal format and the external format. The internal - format supports automatic repair of log files that have not been - properly closed, and makes it possible to efficiently read - logged items in chunks using a set of functions defined - in this module. In fact, this is the only way to read internally - formatted logs. The external format leaves it up to the user to - read the logged deep byte lists. The disk log module cannot - repair externally formatted logs. An item logged to an - internally formatted log must not occupy more than 4 GB of disk - space (the size must fit in 4 bytes). -
-For each open disk log there is one process that handles requests
- made to the disk log; the disk log process is created when
Two types of logs are supported:
+Appends items to a single file, which size can + be limited by the disk log module.
Uses a sequence of wrap log files of limited size. As a + wrap log file is filled up, further items are logged on to the next + file in the sequence, starting all over with the first file when + the last file is filled up.
For efficiency reasons, items are always written to files as binaries.
+ +Two formats of the log files are supported:
+Supports automatic repair of log files that are not + properly closed and enables efficient reading of logged items in + chunks using a set of functions defined in this module. + This is the only way to read internally formatted logs. + An item logged to an internally formatted log must not occupy more + than 4 GB of disk space (the size must fit in 4 bytes).
Leaves it up to the user to read the logged deep byte lists. + The disk log module cannot repair externally formatted logs.
For each open disk log, one process handles requests
+ made to the disk log. This process is created when
+
Owners can subscribe to notifications,
+ messages of the form
For a disk log process to close its file properly and terminate, + it must be closed by its owners and once by some non-owner process + for each time the log was used anonymously. The users are counted + and there must not be any users left when the disk log process terminates.
-Items can be logged synchronously by using the functions
-
Items can be logged synchronously by using functions
+
When using the internal format for logs, the functions
-
When using the internal format for logs, use functions
+
The
A collection of open disk logs with the same name running on
- different nodes is said to be a a distributed disk log
- if requests made to any one of the logs are automatically made to
- the other logs as well. The members of such a collection will be
+ different nodes is said to be a distributed disk log
+ if requests made to any of the logs are automatically made to
+ the other logs as well. The members of such a collection are
called individual distributed disk logs, or just distributed
disk logs if there is no risk of confusion. There is no order
- between the members of such a collection. For instance, logged
- terms are not necessarily written onto the node where the
- request was made before written onto the other nodes. One could
- note here that there are a few functions that do not make
- requests to all members of distributed disk logs, namely
-
An open disk log that is not a distributed disk log is said to be a local disk log. A local disk log is - accessible only from the node where the disk log process runs, + only accessible from the node where the disk log process runs, whereas a distributed disk log is accessible from all nodes in - the Erlang system, with exception for those nodes where a local + the Erlang system, except for those nodes where a local disk log with the same name as the distributed disk log exists. All processes on nodes that have access to a local or - distributed disk log can log items or otherwise change, inspect + distributed disk log can log items or otherwise change, inspect, or close the log.
It is not guaranteed that all log files of a distributed disk log
- contain the same log items; there is no attempt made to synchronize
+ contain the same log items. No attempt is made to synchronize
the contents of the files. However, as long as at least one of
- the involved nodes is alive at each time, all items will be logged.
+ the involved nodes is alive at each time, all items are logged.
When logging items to a distributed log, or otherwise trying to
change the log, the replies from individual logs are
ignored. If all nodes are down, the disk log functions
reply with a
In some applications it may not be acceptable that +
In some applications, it can be unacceptable that replies from individual logs are ignored. An alternative in such - situations is to use several local disk logs instead of one + situations is to use many local disk logs instead of one distributed disk log, and implement the distribution without use - of the disk log module.
+ of theErrors are reported differently for asynchronous log attempts
- and other uses of the disk log module. When used synchronously
- the disk log module replies with an error message, but when called
- asynchronously, the disk log module does not know where to send
- the error message. Instead owners subscribing to notifications will
+ and other uses of the
The disk log module itself does not report errors to the
-
The
The error message
Error message
If an attempt to reopen or truncate a log fails (see
-
The
Returns the names of the disk logs accessible on the current node. + The first list contains local disk logs and the second list contains distributed disk logs.
The
Asynchronously append an item to a disk log.
The owners that subscribe to notifications will receive the
- message
Owners subscribing to notifications receive
+ message
The
Asynchronously append a list of items to a disk log.
+
The owners that subscribe to notifications will receive the
- message
Owners subscribing to notifications receive
+ message
With a call to
Any process can probe a blocked log with
The
Changes the value of option
The
Changes the value of option
The
Changes the size of an open log. + For a halt log, the size can always be increased, + but it cannot be decreased to something less than + the current file size.
-For a wrap log it is always possible to increase both the - size and number of files, as long as the number of files does not +
For a wrap log, both the size and the number of files can always + be increased, as long as the number of files does not exceed 65000. If the maximum number of files is decreased, the - change will not be valid until the current file is full and the + change is not valid until the current file is full and the log wraps to the next file. - The redundant files will be removed next time the log wraps around, - i.e. starts to log to file number 1. + The redundant files are removed the next time the log wraps around, + that is, starts to log to file number 1.
As an example, assume that the old maximum number of files is 10 and that the new maximum number of files is 6. If the current file number is not greater than the new maximum number - of files, the files 7 to 10 will be removed when file number 6 + of files, files 7-10 are removed when file 6 is full and the log starts to write to file number 1 again. - Otherwise the files greater than the current - file will be removed when the current file is full (e.g. if - the current file is 8, the files 9 and 10); the files between - new maximum number of files and the current - file (i.e. files 7 and 8) will be removed next time file number 6 + Otherwise, the files greater than the current + file are removed when the current file is full (for example, if + the current file is 8, files 9 and 10 are removed). The files between + the new maximum number of files and the current + file (that is, files 7 and 8) are removed the next time file 6 is full.
-If the size of the files is decreased the change will immediately - affect the current log. It will not of course change the - size of log files already full until next time they are used. +
If the size of the files is decreased, the change immediately + affects the current log. It does not change the + size of log files already full until the next time they are used.
-If the log size is decreased for instance to save space,
- the function
If the log size is decreased, for example, to save space,
+ function
+
The
Efficiently reads the terms that are appended
+ to an internally formatted log. It minimizes disk
+ I/O by reading 64 kilobyte chunks from the file. Functions
+
The first time
The first time
When
The
The
When
The
Returns the pair
Terms are read from the disk log running on
The function
Can be used with
If the atom
If atom
If the wrap log is not full because all files have not been
- used yet,
If the wrap log is not full because all files are not yet
+ used,
The disk log process in not terminated as long as there are
- owners or users of the log. It should be stressed that each
- and every owner must close the log, possibly by terminating,
- and that any other process - not only the processes that have
- opened the log anonymously - can decrement the
The disk log process is not terminated as long as there are
+ owners or users of the log. All owners must close the log,
+ possibly by terminating. Also, any other process, not only the processes
+ that have opened the log anonymously, can decrement the
If the log is blocked by the closing process, the log is also unblocked. @@ -499,12 +513,14 @@
Given the error returned by any function in this module,
- the function
The
Forces the internally formatted disk log to start logging to the
+ next log file. It can be used, for example, with
The owners that subscribe to notifications will normally
- receive a
Owners subscribing to notifications normally
+ receive a
The
Returns a list of
The following pairs are returned for all logs:
-For halt logs
The information returned by the
+ current invocation of function
If the log is local on
+ the current node,
The following pairs are returned for all logs opened in
Depending on the value of
+ the
The following pair is returned for halt logs opened in
The following pairs are returned for wrap logs opened in
The number of bytes written to the current wrap log file.
The number of items written to the current wrap log file, header inclusive.
The total number of items in all wrap log files.
The ordinal for
the current wrap log file in the range
Note that the
Notice that functions
The function
If there is no log with the given name
- on the specified node,
If no log with the specified name exist on the specified node,
+
The
Synchronously
+ appends a term to a disk log. Returns
The
The owners that subscribe to notifications will be notified
+
Owners subscribing to notifications are notified
of an error with an
The
Synchronously appends a list of items to the log. It is more
+ efficient to use these functions instead of functions
The
The owners that subscribe to notifications will be notified
+
Owners subscribing to notifications are notified
of an error with an
The
Parameter
Specifies the log name. + This name must be passed on as a parameter in all subsequent logging operations. A name must always be supplied.
Specifies the name of the
+ file to be used for logged terms. If this value is
+ omitted and the log name is an atom or a string,
+ the filename defaults to
For wrap logs, this is the base name of the files. Each file in
+ a wrap log is called
If
If
The log type. Defaults to
Disk log format. Defaults to
Log size.
+When a halt log has reached its maximum size, all attempts to
+ log more items are rejected. Defaults to
For wrap logs, parameter
Wrap logs write at most
When opening an existing wrap log, it is not
+ necessary to supply a value for option
This option can be used for
+ adding members to a distributed disk log.
+ Defaults to
If
Sent when a wrap log has
filled up one of its files and a new file is
opened.
Sent when a log is
truncated or reopened. For halt logs
Sent when an asynchronous log attempt is made to
a log file opened in read-only mode.
Sent when an asynchronous log attempt is made to
a blocked log that does not queue log attempts.
Sent when function
Sent when
an attempt to log items to a wrap log would write more
- bytes than the limit set by the
Sent when the error status changes. The error status
is defined by the outcome of the last attempt to log
- items to a the log or to truncate the log or the last
- use of
Specifies a header to be
written first on the log file. If the log is a wrap
log, the item
Specifies a function
to be called each time a new log file is opened.
The call
Specifies if the log is to be
+ opened in read-only or read-write mode. Defaults to
The
When a disk log is opened in read-write mode, any existing
- log file is checked for. If there is none a new empty
+ log file is checked for. If there is none, a new empty
log is created, otherwise the existing file is opened at the
position after the last logged item, and the logging of items
- will commence from there. If the format is
The
If an owner attempts to open a log
+ as owner once again, it is acknowledged with the return value
If a log with a given name is local on some node, + affected.
If a log with a specified name is local on some node,
and one tries to open the log distributed on the same node,
- then the tuple
It is possible to open a log file more than once by giving
- different values to the option
A log file can be opened more than once by giving
+ different values to option
If an attempt to open a log file for the first time fails,
the disk log process terminates with the EXIT message
@@ -999,9 +1045,9 @@ If
The Returns the log name
given the pid of a disk log process on the current node, or
- This function is meant to be used for debugging only.
The Renames the log file
+ to The The owners that subscribe to notifications will receive
+ Owners subscribing to notifications receive
a Upon failure to reopen the log, the disk log process terminates
- with the EXIT message The Ensures that the contents of the log are written to the disk.
This is usually a rather expensive operation.
The Removes all items from a disk log.
+ If argument The The owners that subscribe to notifications will receive
+ Owners subscribing to notifications receive
a If the attempt to truncate the log fails, the disk log process
terminates with the EXIT message
- The Unblocks a log.
A log can only be unblocked by the blocking process.
This server is used to assist diskless Erlang nodes which fetch
+ This server is used to assist diskless Erlang nodes that fetch
all Erlang code from another machine. This server is used to fetch all code, including the start
script, if an Erlang runtime system is started with
- the This server can be started with the This server can be started with the The The support for loading of code from archive files is
- experimental. The sole purpose of releasing it before it is ready
- is to obtain early feedback. The file format, semantics,
- interfaces etc. may be changed in a future release. The The support for loading code from archive files is
+ experimental. It is released before it is ready
+ to obtain early feedback. The file format, semantics,
+ interfaces, and so on, can be changed in a future release. Starts the boot server. Adds a Starts the boot server and links to the caller. This function
- is used to start the server if it is included in a supervision
- tree. Deletes a Adds a Starts the boot server. Deletes a Starts the boot server and links to the caller. This function
+ is used to start the server if it is included in a supervision
+ tree. Returns the current list of allowed slave hosts. The This module provides an interface for loading
+ and unloading Erlang linked-in drivers in runtime. This is a large reference document. For casual use of the
- module, as well as for most real world applications, the
- descriptions of the functions This is a large reference document. For casual use of this
+ module, and for most real world applications, the
+ descriptions of functions
+ The driver should be provided as a dynamically linked library
- in a object code format specific for the platform in use,
- i. e. The driver is to be provided as a dynamically linked library
+ in an object code format specific for the platform in use,
+ that is,
When describing a set of functions, (i.e. a module, a part of a - module or an application) executing in a process and wanting to - use a ddll-driver, we use the term user. There can be - several users in one process (different modules needing the same - driver) and several processes running the same code, making up - several users of a driver. In the basic scenario, each - user loads the driver before starting to use it and unloads the - driver when done. The reference counting keeps track of - processes as well as the number of loads by each process, so that - the driver will only be unloaded when no one wants it - (it has no user). The driver also keeps track of ports that are - opened towards it, so that one can delay unloading until all - ports are closed or kill all ports using the driver when it is - unloaded.
+When describing a set of functions (that is, a module, a part of a + module, or an application), executing in a process and wanting to + use a ddll-driver, we use the term user. A process can + have many users (different modules needing the same + driver) and many processes running the same code, making up + many users of a driver.
+In the basic scenario, each user loads the driver before + starting to use it and unloads the driver when done. + The reference counting keeps track of + processes and the number of loads by each process. This way + the driver is only unloaded when no one wants it (it has no user). + The driver also keeps track of ports that are + opened to it. This enables delay of unloading until all + ports are closed, or killing of all ports that use the driver when + it is unloaded.
The interface supports two basic scenarios of loading and unloading. Each scenario can also have the option of either killing ports when the driver is unloading, or waiting for the - ports to close themselves. The scenarios are:
+ ports to close themselves. The scenarios are as follows:This (most common) scenario simply supports that each
Each
Two pairs of functions support this scenario:
+ demanding load, but the +The following two pairs of functions support this scenario:
When using the
If a process having the driver loaded dies, it will have - the same effect as if unloading was done.
-When loading, the function
If a process having the driver loaded dies, it has + the same effect as if unloading is done.
+When loading, function
These interfaces is intended to be used when it is considered an
- error that ports are open towards a driver that no
These interfaces are intended to be used when it is considered an
+ error that ports are open to a driver that no
+
The function names
This scenario occurs when the driver code might need +
This scenario can occur if the driver code needs
replacement during operation of the Erlang
- emulator. Implementing driver code replacement is somewhat
- more tedious than beam code replacement, as one driver
- cannot be loaded as both "old" and "new" code. All
The actual unloading/loading is done as one atomic +
The unloading/loading is done as one atomic operation, blocking all processes in the system from using - the driver concerned while in progress.
+ the driver in question while in progress.The preferred way to do driver code replacement is to let
one single process keep track of the driver. When
- the process start, the driver is loaded. When replacement
+ the process starts, the driver is loaded. When replacement
is required, the driver is reloaded. Unload is probably never
- done, or done when the process exits. If more than one
Demanding reload when a reload is already in progress is
- always an error. Using the high level functions, it is also
- an error to demand reloading when more than one
The two functions for reloading drivers should be used
- together with corresponding load functions, to support the two
+ always an error. Using the high-level functions, it is also
+ an error to demand reloading when more than one
+
To simplify driver replacement, avoid designing your system so
+ that more than one
+
The two functions for reloading drivers are to be used + together with corresponding load functions to support the two different behaviors concerning open ports:
This pair of functions is used when reloading should be - done after the last open port towards the driver is +
This pair of functions is used when reloading is to be + done after the last open port to the driver is closed.
-As
As
This pair of functions are used when open ports towards - the driver should be killed with reason +
This pair of functions are used when open ports to
+ the driver are to be killed with reason
If, however, another process has the driver loaded,
- calling
However, if another process has the driver loaded,
+ calling
Removes a driver monitor in much the same way as
-
The function throws a
Takes an
Because of peculiarities in the dynamic loading interfaces on + different platforms, the returned string is only guaranteed + to describe the correct error if format_error/1 is called + in the same instance of the Erlang virtual machine as the error + appeared in (meaning the same operating + system process).
+Returns a list of tuples
Returns a list of tuples
Returns a list of tuples
The different tags that will appear in the list are:
+Returns a list of tuples
The following tags appears in the list:
For a detailed description of each value, please read the
- description of
For a detailed description of each value, see
+
The function throws a
This function returns specific information about one aspect
- of a driver. The
Returns specific information about one aspect of a driver.
+ Parameter
Return all processes containing
Returns all processes containing
+
Return a list of the driver options provided when
- loading, as well as any options set by the driver itself
- during initialization. The currently only valid option
- being
Returns a list of the driver options provided when
+ loading, and any options set by the driver
+ during initialization. The only valid option
+ is
Return the number of ports (an
Returns the number of ports (an
Return a
Returns a
Return a
Returns a
Return a list of all processes having monitors for
-
Returns a list of all processes having monitors for
+
Return a list of all processes having monitors for
-
Returns a list of all processes having monitors for
+
If the options
If option
The function throws a
Loads and links the dynamic driver
Loads and links the dynamic driver
The
The
If the driver has been previously unloaded, but is still
- present due to open ports against it, a call to
-
If the driver was previously unloaded, but is still
+ present because of open ports to it, a call to
+
If more than one process tries to load an already loaded
- driver withe the same
It is not allowed to load
- several drivers with the same name but with different
-
It is not allowed to load multiple drivers with
+ the same name but with different
Note especially that the
On success, the function returns
For more control over the error handling, again use the
-
For more control over the error handling, use the
+
The function throws a
Works essentially as
The number of loads and unloads by different
Works essentially as
The number of loads and unloads by different
+
This interface (or at least the name of the functions) is
- kept for backward compatibility. Using
The function throws a
Returns a list of all the available drivers, both + (statically) linked-in and dynamically loaded ones.
+The driver names are returned as a list of strings rather + than a list of atoms for historical reasons.
+For more information about drivers, see
+
This function creates a driver monitor and works in many
- ways as the function
Creates a driver monitor and works in many
+ ways as
+
As with process monitors, each driver monitor set will only
- generate one single message. The monitor is
- "destroyed" after the message is sent and there is then no
- need to call
The
As with process monitors, each driver monitor set only
+ generates one single message. The monitor is
+ "destroyed" after the message is sent, so it is then not
+ needed to call
+
The function accepts the following parameters:
The monitor tag is always
The monitor tag is always
The
Parameter
Notify me when the driver is reloaded (or loaded if +
Notifies when the driver is reloaded (or loaded if
loading is underway). It only makes sense to monitor
drivers that are in the process of being loaded or
- reloaded. One cannot monitor a future-to-be driver
- name for loading, that will only result in a
-
Setting a driver monitor for
Setting a driver monitor for
This message is sent, either immediately if the +
This message is sent either immediately if the driver is already loaded and no reloading is pending, or when reloading is executed if reloading is pending.
The
This message will be sent if reloading was +
This message is sent if reloading was expected, but the (old) driver made itself - permanent prior to reloading. It will also be + permanent before reloading. It is also sent if the driver was permanent or statically - linked in when trying to create the monitor.
+ linked-in when trying to create the monitor.This message will arrive if reloading was
- underway, but the
This message arrives if reloading was
+ underway, but the requesting
+
This message will arrive if reloading was +
This message arrives if reloading was
underway but the loading for some reason
failed. The
Monitor when a driver gets unloaded. If one +
Monitors when a driver gets unloaded. If one monitors a driver that is not present in the system, - one will immediately get notified that the driver got + one immediately gets notified that the driver got unloaded. There is no guarantee that the driver was - actually ever loaded.
-A driver monitor for unload will eventually result + ever loaded.
+A driver monitor for unload eventually results in one of the following messages being sent:
The driver instance monitored is now
- unloaded. As the unload might have been due to a
-
The monitored driver instance is now
+ unloaded. As the unload can be a result of a
+
This message will be sent if unloading was +
This message is sent if unloading was
expected, but while the driver was waiting for
- all ports to get closed, a new
This message appears when an
If one wants to really monitor when the
- driver gets unloaded, this message will distort
- the picture, no unloading was really done.
- The
This message appears if
If one really wants to monitor when the
+ driver gets unloaded, this message distorts
+ the picture, because no unloading was done.
+ Option
This message will be sent if unloading was +
This message is sent if unloading was expected, but the driver made itself - permanent prior to unloading. It will also be + permanent before unloading. It is also sent if trying to monitor a permanent or - statically linked in driver.
+ statically linked-in driver.A monitor created as
The function throws a
Reloads the driver named
If there are other
Avoid mixing
- several
If one wants to avoid hanging on open ports, one should use
- the
The
Avoid mixing
- several
Avoid mixing multiple
+
To avoid hanging on open ports, use function
+
The
On success, the function returns
For more control over the error handling, again use the
-
For more control over the error handling, use the
+
The function throws a
Works exactly as
As this interface implies that ports are being killed when - the last user disappears, the function wont hang waiting for +
Works exactly as
As this interface implies that ports are killed when + the last user disappears, the function does not hang waiting for ports to get closed.
-For further details, see the
For more details, see
+
The function throws a
This function provides more control than the +
Provides more control than the
The driver was actually loaded and is immediately - usable.
+The driver was loaded and is immediately usable.
The driver was already loaded by another process
- and/or is in use by a living port. The load by you is
+ or is in use by a living port, or both. The load by you is
registered and a corresponding
The load request is registered, but the loading is
- delayed due to the fact that an earlier instance of the
- driver is still waiting to get unloaded (there are open
- ports using it). Still, unload is expected when you are
- done with the driver. This return value will
- mostly happen when the
+ delayed because an earlier instance of the
+ driver is still waiting to get unloaded (open
+ ports use it). Still, unload is expected when you are
+ done with the driver. This return value
+ mostly occurs when options
The load request is registered, but the loading is
- delayed due to the fact that an earlier instance of the
+ delayed because an earlier instance of the
driver is still waiting to get unloaded by another
When the function returns
When monitoring is requested, and a corresponding
When monitoring is requested, and a corresponding
+
Note that in case of loading, monitoring can
- not only get triggered by using the
In case of loading, monitoring can not only get
+ triggered by using option
The function accepts the following parameters:
The filesystem path to the directory where the driver - object file is situated. The filename of the object file +
The file system path to the directory where the driver
+ object file is located. The filename of the object file
(minus extension) must correspond to the driver name
- (used in the name parameter) and the driver must
- identify itself with the very same name. The
-
The (possibly flattened)
The name parameter is the name of the driver to be used
- in subsequent calls to
This parameter is the name of the driver
+ to be used in subsequent calls to function
+
A number of options can be specified to control the - loading operation. The options are given as a list of - two-tuples, the tuples having the following values and +
Some options can be specified to control the + loading operation. The options are specified as a list of + two-tuples. The tuples have the following values and meanings:
This option is to provide options that will change - its general behavior and will "stick" to the driver +
This is to provide options that changes + its general behavior and "sticks" to the driver throughout its lifespan.
-The driver options for a given driver name need - always to be consistent, even when the driver is reloaded, meaning that they are as much a part - of the driver as the actual name.
-Currently the only allowed driver option is +
The driver options for a specified driver name need + always to be consistent, even when the driver is reloaded, + meaning that they are as much a part of the driver as the name.
+The only allowed driver option is
A
Only one
If reloading is not requested, it might still be
- useful to specify the
Only one
The atom
The atom
Option
If reloading is not requested, it can still be
+ useful to specify option
This option is used when one wants to +
This option is used to
reload a driver from disk, most often in a
code upgrade scenario. Having a
To reload a driver, the process needs to have previously
- loaded the driver, i.e there has to be an active
The
The more useful option is
If the driver is unloaded (not present in the
- system), the error code
-
To reload a driver, the process must have loaded the driver
+ before, that is, there must be an active
+
The
With the atom
The option also triggers port-killing (if driver
+ option
This option is more useful. Here, reloading is queued
+ if the driver is not loaded by any other
+
If the driver is unloaded (not present in the system),
+ error code
The function might return numerous errors, of which some - only can be returned given a certain combination of options.
-A number of errors are opaque and can only be interpreted by
- passing them to the
The function can return numerous errors, some + can only be returned given a certain combination of options.
+Some errors are opaque and can only be interpreted by
+ passing them to function
+
The driver with the specified name is an erlang - statically linked in driver, which cannot be manipulated +
The driver with the specified name is an Erlang + statically linked-in driver, which cannot be manipulated with this API.
The driver has already been loaded with either other
-
This can happen even if a
The driver is already loaded with other
+
This can occur even if a
The driver has requested itself to be permanent, making - it behave like an erlang linked in driver and it can no + it behave like an Erlang linked-in driver and can no longer be manipulated with this API.
The driver is loaded by other
The driver is loaded by other
+
Driver reload is already requested by another
Driver reload is already requested by another
+
Appears when the
Appears when option
Appears when the
Appears when option
All other error codes are to be translated by the
If the arguments or options are malformed, the function will
- throw a
All other error codes are to be translated by function
+
If the arguments or options are malformed, the function
+ throws a
This is the low level function to unload (or decrement +
This is the low-level function to unload (or decrement
reference counts of) a driver. It can be used to force port
killing, in much the same way as the driver option
-
Unloading can be described as the process of telling the
emulator that this particular part of the code in this
- particular process (i.e. this
To allow the
The possible monitor messages that can be expected are the
- same as when using the
The function will return one of the following statuses upon
+ particular process (that is, this
+
If the driver has option
To allow the
If option
The possible monitor messages to expect are the
+ same as when using option
The function returns one of the following statuses upon success:
The driver was immediately unloaded, meaning that the driver name is now free to use by other drivers and, if the underlying OS permits it, the memory occupied by the driver object code is now reclaimed.
The driver can only be unloaded when there are no open
- ports using it and there are no more
This return value indicates that this call removed the
- last
Indicates that this call removed the last
+
This return value is valid even when the option
-
This return value is valid even if option
The unload request is registered, but there are still
- other
The unload request is registered, but
+ other
This is a normal, healthy return value if the call was +
This is a normal, healthy, return value if the call was
just placed to inform the emulator that you have no
- further use of the driver. It is actually the most
- common return value in the most common
The function accepts the following parameters:
The name parameter is the name of the driver to be
- unloaded. The name can be specified either as an
-
The
Argument
Force killing of all ports opened using this driver,
- with the exit reason
If there are other
If one wants the consistent behavior of killing ports +
Forces killing of all ports opened using this driver,
+ with exit reason
If other
To get the consistent behavior of killing ports
when the last
This option creates a driver monitor if the condition
- given in
Creates a driver monitor if the condition
+ specified in
Create a driver monitor if the return value is to +
Creates a driver monitor if the return value is to
be
Create a monitor if the return value will be either +
Creates a monitor if the return value is
The
By using the monitor-triggers in the call to
-
The
Using the monitor triggers in the call to
+
The function may return several error conditions, of which - all are well specified (no opaque values):
+The function can return the following error conditions, + all well specified (no opaque values):
You were trying to unload an erlang statically linked in +
You were trying to unload an Erlang statically linked-in driver, which cannot be manipulated with this interface (and cannot be unloaded at all).
The driver
The driver
As a special case, drivers can be unloaded from
- processes that has done no corresponding call to
-
The driver has made itself permanent, in which case it can no longer be manipulated by this interface (much - like a statically linked in driver).
+ like a statically linked-in driver).The function throws a
Unloads, or at least dereferences the driver named
-
If there are other
If there are other
The
The function throws a
Unloads, or at least dereferences the driver named
-
If there are other
The
The function throws a
Returns a list of all the available drivers, both - (statically) linked-in and dynamically loaded ones.
-The driver names are returned as a list of strings rather - than a list of atoms for historical reasons.
-More information about drivers can be obtained using one of
- the
Takes an
Due to peculiarities in the dynamic loading interfaces on - different platform, the returned string is only guaranteed - to describe the correct error if format_error/1 is called in the same instance of the erlang virtual machine as the error appeared in (meaning the same operating - system process)!
-erl_driver(4), driver_entry(4)
+The error handler module defines what happens when certain types +
This module defines what happens when certain types of errors occur.
Raises an
This function is called by the run-time system if a call is made to +
This function is called by the runtime system if a call is made to
This function will first attempt to autoload +
This function first attempts to autoload
If it was possible to load
If it is possible to load
Otherwise, if the function
Otherwise, if function
Defining
Otherwise an
Raise an
Otherwise an
This function is evaluated if a call is made to
-
If
Otherwise, it returns, if possible, the value of
-
The code in
The code in
Changes in the code which may seem small can cause a deadlock
- as unforeseen consequences may occur. The use of
Code changes that seem small can cause a deadlock,
+ as unforeseen consequences can occur. The use of
The Erlang error logger is an event manager (see
Initially,
Initially,
Also the SASL application, if started, adds its own event
- handler, which by default writes supervisor, crash and progress
- reports to tty. See
-
It is recommended that user defined applications should report
- errors through the error logger, in order to get uniform reports.
- User defined event handlers can be added to handle application
- specific events. (
Also the
It is recommended that user-defined applications report
+ errors through the error logger to get uniform reports.
+ User-defined event handlers can be added to handle application-specific
+ events, see
+
Warning events were introduced in Erlang/OTP R9C and are enabled
- by default as of 18.0. To retain backwards compatibility with existing
- user defined event handlers, these may be tagged as errors or info
- using the command line flag
Adds a new event handler to the error logger. The event
+ handler must be implemented as a
The event handler must be able to handle the events in this module, see
+ section
Deletes an event handler from the error logger by calling
+
Sends a standard error event to the error logger.
- The
Example:
1> error_logger:error_msg("An error occurred in ~p~n", [a_module]).
@@ -90,16 +122,19 @@ ok
If called with bad arguments, this function can crash
the standard event handler, meaning no further events are
- logged. When in doubt, use
Sends a standard error report event to the error logger. The event is handled by the standard event handler.
+Example:
2> error_logger:error_report([{tag1,data1},a_term,{tag2,data}]).
@@ -117,100 +152,27 @@ ok
Sends a user defined error report event to the error logger. +
Sends a user-defined error report event to the error logger. An event handler to handle the event is supposed to have been added. The event is ignored by the standard event handler.
It is recommended that
Returns the current mapping for warning events. Events sent
- using
-os$ erl
-Erlang (BEAM) emulator version 5.4.8 [hipe] [threads:0] [kernel-poll]
-
-Eshell V5.4.8 (abort with ^G)
-1> error_logger:warning_map().
-warning
-2> error_logger:warning_msg("Warnings tagged as: ~p~n", [warning]).
-
-=WARNING REPORT==== 11-Aug-2005::15:31:55 ===
-Warnings tagged as: warning
-ok
-3>
-User switch command
- --> q
-os$ erl +W e
-Erlang (BEAM) emulator version 5.4.8 [hipe] [threads:0] [kernel-poll]
-
-Eshell V5.4.8 (abort with ^G)
-1> error_logger:warning_map().
-error
-2> error_logger:warning_msg("Warnings tagged as: ~p~n", [error]).
-
-=ERROR REPORT==== 11-Aug-2005::15:31:23 ===
-Warnings tagged as: error
-ok
- Sends a standard warning event to the error logger.
- The
If called with bad arguments, this function can crash
- the standard event handler, meaning no further events are
- logged. When in doubt, use
Sends a standard warning report event to the error logger.
- The event is handled by the standard event handler. It is
- tagged either as an error, warning or info, see
-
Sends a user defined warning report event to the error
- logger. An event handler to handle the event is supposed to
- have been added. The event is ignored by the standard event
- handler. It is tagged either as an error, warning or info,
- depending on the value of
-
Sends a standard information event to the error logger.
- The
Example:
1> error_logger:info_msg("Something happened in ~p~n", [a_module]).
@@ -226,10 +188,11 @@ ok
Sends a standard information report event to the error logger. The event is handled by the standard event handler.
+Example:
2> error_logger:info_report([{tag1,data1},a_term,{tag2,data}]).
@@ -247,59 +210,22 @@ ok
Sends a user defined information report event to the error +
Sends a user-defined information report event to the error logger. An event handler to handle the event is supposed to have been added. The event is ignored by the standard event handler.
It is recommended that
Adds a new event handler to the error logger. The event
- handler must be implemented as a
The event handler must be able to handle the
-
Deletes an event handler from the error logger by calling
-
Enables (
This is done by adding or deleting the standard event handler
- for output to tty, thus calling this function overrides
- the value of the Kernel
Enables or disables printout of standard events to a file.
This is done by adding or deleting the standard event handler
- for output to file, thus calling this function overrides
- the value of the Kernel
Enabling file logging can be used in combination with calling
-
Enabling file logging can be used together with calling
+
Opens the log file
Opens log file
Enables (
This is done by adding or deleting the standard event handler
+ for output to the terminal. Thus, calling this function overrides
+ the value of the
Returns the current mapping for warning events. Events sent
+ using
Example:
+
+os$ erl
+Erlang (BEAM) emulator version 5.4.8 [hipe] [threads:0] [kernel-poll]
+
+Eshell V5.4.8 (abort with ^G)
+1> error_logger:warning_map().
+warning
+2> error_logger:warning_msg("Warnings tagged as: ~p~n", [warning]).
+
+=WARNING REPORT==== 11-Aug-2005::15:31:55 ===
+Warnings tagged as: warning
+ok
+3>
+User switch command
+ --> q
+os$ erl +W e
+Erlang (BEAM) emulator version 5.4.8 [hipe] [threads:0] [kernel-poll]
+
+Eshell V5.4.8 (abort with ^G)
+1> error_logger:warning_map().
+error
+2> error_logger:warning_msg("Warnings tagged as: ~p~n", [error]).
+
+=ERROR REPORT==== 11-Aug-2005::15:31:23 ===
+Warnings tagged as: error
+ok
+ Sends a standard warning event to the error logger.
+ The
If called with bad arguments, this function can crash
+ the standard event handler, meaning no further events are
+ logged. When in doubt, use
Sends a standard warning report event to the error logger.
+ The event is handled by the standard event handler. It is
+ tagged as an error, warning, or info, see
+
Sends a user-defined warning report event to the error
+ logger. An event handler to handle the event is supposed to
+ have been added. The event is ignored by the standard event
+ handler. It is tagged as an error, warning, or info,
+ depending on the value of
+
All event handlers added to the error logger must handle
the following events.
Generated when
Generated when
Generated when
Generated when
Generated when
Generated when
Generated when
Note that also a number of system internal events may be - received, a catch-all clause last in the definition of +
Notice that some system-internal events can also be
+ received. Therefore a catch-all clause last in the definition of
the event handler callback function
gen_event(3), log_mf_h(3), kernel(6), sasl(6)
+The module
On operating systems with thread support, it is possible to let - file operations be performed in threads of their own, allowing +
This module provides an interface to the file system.
+ +On operating systems with thread support,
+ file operations can be performed in threads of their own, allowing
other Erlang processes to continue executing in parallel with
- the file operations. See the command line flag
-
With regard to file name encoding, the Erlang VM can operate in
- two modes. The current mode can be queried using the
Regarding filename encoding, the Erlang VM can operate in
+ two modes. The current mode can be queried using function
+
In the
In
The default mode depends on the operating system. Windows and
- MacOS X enforce consistent file name encoding and therefore the
- VM uses the
On operating systems with transparent naming (i.e. all Unix
- systems except MacOS X), the default will be
On operating systems with transparent naming (for example, all Unix
+ systems except MacOS X), default is
On operating systems with transparent naming, files could be
- inconsistently named, i.e. some files are encoded in UTF-8 while
- others are encoded in (for example) iso-latin1. To be able to
- handle file systems with inconsistent naming when running in the
-
On operating systems with transparent naming, files can be
+ inconsistently named, for example, some files are encoded in UTF-8 while
+ others are encoded in ISO Latin-1. The concept of raw filenames is
+ introduced to handle file systems with inconsistent naming when running in
+
A raw file name is a file name given as a binary. The Erlang VM - will perform no translation of a file name given as a binary on +
A raw filename is a filename specified as a binary. The Erlang VM + does not translate a filename specified as a binary on systems with transparent naming.
-When running in the
When running in
Also see
See also section
As returned by
-
If VM is in Unicode filename mode,
If VM is in Unicode filename mode,
An atom which is named from the POSIX error codes used in +
An atom that is named from the POSIX error codes used in Unix, and in the runtime libraries of most C compilers.
This function only succeeds in platforms that implement this +
This function only succeeds in platforms that provide this feature. When it succeeds, space is preallocated for the file but the file size might not be updated. This behaviour depends on the - preallocation implementation. To guarantee the file size is updated - one must truncate the file to the new size.
+ preallocation implementation. To guarantee that the file size is updated, + truncate the file to the new size.Changes group of a file. See
-
Changes permissions of a file. See
-
Changes owner of a file. See
-
Changes owner and group of a file. See
-
Changes the modification and access times of a file. See
-
Changes the modification and last access times of a file. See
-
Closes the file referenced by
Note that if the option
Notice that if option
Reads Erlang terms, separated by '.', from
An error occurred when opening the file or reading it.
- See
An error occurred when interpreting the Erlang terms in
- the file. Use
Example:
-f.txt: {person, "kalle", 25}.
+ Example:
+
+f.txt: {person, "kalle", 25}.
{person, "pelle", 30}.
-1> file:consult("f.txt").
+
+1> file:consult("f.txt").
{ok,[{person,"kalle",25},{person,"pelle",30}]}
- The encoding of of Filename can be set
- by a comment as described in epp(3) .
+ The encoding of Filename can be set
+ by a comment, as described in
+ stdlib:epp(3) .
Copies
The argument
Argument
If both
If
Returns
Returns
Typical error reasons: As for
Typical error reasons: as for
+
Ensures that any buffers kept by the operating system
+ (not by the Erlang runtime system) are written to disk. In
+ many ways it resembles
Applications that access databases or log files often write
+ a tiny data fragment (for example, one line in a log file) and then
+ call
Available only in some POSIX systems, this call results in a
+ call to
Tries to delete the directory
Tries to delete directory
Typical error reasons are:
+Typical error reasons:
Tries to delete the file
Tries to delete file
Typical error reasons are:
+Typical error reasons:
The file is a directory and the user is not super-user.
+The file is a directory and the user is not superuser.
A component of the file name is not a directory. On some +
A component of the filename is not a directory. On some
platforms,
In a future release, a bad type for the
-
In a future release, a bad type for argument
+
Reads and evaluates Erlang expressions, separated by '.' (or
- ',', a sequence of expressions is also an expression), from
-
An error occurred when opening the file or reading it.
- See
An error occurred when interpreting the Erlang
- expressions in the file. Use
The encoding of of
The encoding of
The same as
The same as
Given the error reason returned by any function in this module, returns a descriptive string of the error in English.
@@ -439,17 +469,17 @@Returns
In rare circumstances, this function can fail on Unix. - It may happen if read permission does not exist for + It can occur if read permission does not exist for the parent directories of the current directory.
Typical error reasons are:
+A typical error reason:
Returns
This function returns
Typical error reasons are:
+ is the current working directory of the specified drive. + +Returns
Typical error reasons:
Lists all files in a directory, except files
- with "raw" names. Returns
-
Typical error reasons are:
+Typical error reasons:
Typical error reasons are:
+Typical error reasons:
Tries to create the directory
Tries to create directory
Typical error reasons are:
+Typical error reasons:
There is already a file or directory named
A file or directory named
There is a no space left on the device.
+No space is left on the device.
Makes a hard link from
Typical error reasons:
This function creates a symbolic link
Creates a symbolic link
Typical error reasons:
Opens the file
Opens file
The file is opened for writing. It is created if it does
- not exist. If the file exists, and if
The file will be opened for writing, and it will be
- created if it does not exist. Every write operation to a
- file opened with
The file is opened for writing. It is created if it does
+ not exist. Every write operation to a file opened with
+
The file, when opened for writing, is created if it
- does not exist. If the file exists, open will return
-
The file is opened for writing. It is created if it does
+ not exist. If the file exists,
This option does not guarantee exclusiveness on
- file systems that do not support O_EXCL properly,
+ file systems not supporting
The functions in the
Especially if
Only the Erlang process that opened the file can use + it.
A remote Erlang file server cannot be used. + The computer on which the Erlang node is running must have access to the file system (directly or through - NFS).
When this option has been given, read operations on the file - will return binaries rather than lists.
+Read operations on the file return binaries rather than lists.
If this option is used, the data in subsequent
-
Data in subsequent
+
The purpose of this option is to increase performance
- by reducing the number of operating system calls, so the
-
When this option is used, the result of
For example, when
The same as
This option activates read data buffering. If +
Activates read data buffering. If
The
The
If The same as
Makes it possible to read or write gzip compressed
- files. The
Makes the file perform automatic translation of characters to and from a specific (Unicode) encoding. Note that the data supplied to file:write or returned by file:read still is byte oriented, this option only denotes how data is actually stored in the disk file.
-Depending on the encoding, different methods of reading and writing data is preferred. The default encoding of
If data is sent to an
The allowed values for
Makes the file perform automatic translation of characters to
+ and from a specific (Unicode) encoding. Notice that the data supplied
+ to
+
Depending on the encoding, different methods of reading and writing
+ data is preferred. The default encoding of
If data is sent to an
Allowed values for
The default encoding. Bytes supplied to i.e. file:write are written as is on the file, likewise bytes read from the file are returned to i.e. file:read as is. If the
The default encoding. Bytes supplied to the file, that is,
+
Characters are translated to and from the UTF-8 encoding before being written to or read from the file. A file opened in this way might be readable using the file:read function, as long as no data stored on the file lies beyond the ISO-latin-1 range (0..255), but failure will occur if the data contains Unicode codepoints beyond that range. The file is best read with the functions in the Unicode aware
Bytes written to the file by any means are translated to UTF-8 encoding before actually being stored on the disk file.
+Characters are translated to and from UTF-8 encoding before they are
+ written to or read from the file. A file opened in this way can be
+ readable using function
+
Bytes written to the file by any means are translated to UTF-8 encoding + before being stored on the disk file.
Works like
Works like
Works like
Works like
Works like
Works like
Works like
Works like
The Encoding can be changed for a file "on the fly" by using the
The Encoding can be changed for a file "on the fly" by using function
+
This option is not allowed on
On platforms that support it, enables the POSIX
On platforms supporting it, enables the POSIX
Returns:
The file has been opened in the requested mode. +
The file is opened in the requested mode.
The file could not be opened.
+The file cannot be opened.
In previous versions of
In previous versions of
The named file is not a regular file. It may be a - directory, a fifo, or a device.
+The named file is not a regular file. It can be a + directory, a FIFO, or a device.
A component of the file name is not a directory. On some +
A component of the filename is not a directory. On some
platforms,
There is a no space left on the device (if
There is no space left on the device (if
Searches the path
Returns one of the following:
The file was successfully read.
The file is successfully read.
The file could not be found in any of the directories in +
The file cannot be found in any of the directories in
An error occurred when opening the file or reading it.
- See
An error occurred when interpreting the Erlang terms in
- the file. Use
The encoding of of
The encoding of
Searches the path
Returns one of the following:
The file was read and evaluated.
The file is read and evaluated.
The file could not be found in any of the directories in +
The file cannot be found in any of the directories in
An error occurred when opening the file or reading it.
- See
An error occurred when interpreting the Erlang
- expressions in the file. Use
The encoding of of
The encoding of
Searches the path
Returns one of the following:
The file has been opened in the requested mode. +
The file is opened in the requested mode.
The file could not be found in any of the directories in +
The file cannot be found in any of the directories in
The file could not be opened.
+The file cannot be opened.
Searches the path
Returns one of the following:
The file was read and evaluated.
The file is read and evaluated.
The file could not be found in any of the directories in +
The file cannot be found in any of the directories in
An error occurred when opening the file or reading it.
- See
An error occurred when interpreting the Erlang
- expressions in the file. Use
The encoding of of
The encoding of
The same as
If
If
If this node's file server is not a slave, the file was - opened by this node's file server, (this implies that +
If the file server of this node is not a slave, the file was
+ opened by the file server of this node (this implies that
Sets the position of the file referenced by
The same as above with
Note that offsets are counted in bytes, not in characters. If the file is opened using some other
Typical error reasons are:
+Notice that offsets are counted in bytes, not in characters. If the file
+ is opened using some other
A typical error reason is:
Either
Either
Performs a sequence of
As the position is given as a byte-offset, special caution has to be taken when working with files where
As the position is specified as a byte-offset, take special caution
+ when working with files where
Combines
As the position is given as a byte-offset, special caution has to be taken when working with files where
As the position is specified as a byte-offset, take special caution
+ when working with files where
Performs a sequence of
When positioning in a file with other
When positioning in a file with other
Combines
When positioning in a file with other
When positioning in a file with other
Reads
For files where
Also, if
For files where
Also, if
The function returns:
If the file was opened in binary mode, the read bytes are returned in a binary, otherwise in a list. The list or - binary will be shorter than the number of bytes requested + binary is shorter than the number of bytes requested if end of file was reached.
The file was opened with another
The file is opened with another
Returns A component of the file name is not a directory. On some
+ A component of the filename is not a directory. On some
platforms, Retrieves information about a file. Returns
The time type returned in If the
- Since file times is stored in posix time on most OS it is
- faster to query file information with the The time type returned in Returns local time. Returns universal time. Returns seconds since or before Unix time epoch,
+ which is 1970-01-01 00:00 UTC. Default is If the option As file times are stored in POSIX time on most OS, it is faster to
+ query file information with option The record The record The current system access to the file. The last time the file was read. The last time the file was written. The interpretation of this time field depends on
the operating system. On Unix, it is the last time
- the file or the inode was changed. In Windows, it is
+ the file or the The file permissions as the sum of the following bit
values: read permission: owner write permission: owner execute permission: owner read permission: group write permission: group execute permission: group read permission: other write permission: other execute permission: other set user id on execution set group id on execution On Unix platforms, other bits than those listed above
- may be set. On Unix platforms, the following bits
+ can also be set: Number of links to the file (this will always be 1 for
- file systems which have no concept of links). Number of links to the file (this is always 1 for
+ file systems that have no concept of links). Gives the
--include_lib("kernel/include/file.hrl").
-
Indicates the owner of the file. Will be zero for - non-Unix file systems.
+Indicates the owner of the file. On non-Unix file systems, + this field is zero.
Gives the group that the owner of the file belongs to. - Will be zero for non-Unix file systems.
+ On non-Unix file systems, this field is zero.Typical error reasons:
@@ -1399,7 +1526,7 @@A component of the file name is not a directory. On some +
A component of the filename is not a directory. On some
platforms,
Reads a line of bytes/characters from the file referenced by
-
The function can be used on files opened in
If
The function can be used on files opened in
If
The function returns:
One line from the file is returned, including the trailing LF, but with CRLF sequences replaced by a single LF (see above).
-If the file was opened in binary mode, the read bytes are +
One line from the file is returned, including the trailing LF, + but with CRLF sequences replaced by a single LF (see above).
+If the file is opened in binary mode, the read bytes are returned in a binary, otherwise in a list.
The file is was opened with another
The file is opened with another
Typical error reasons:
This function returns
Returns
Note that
Notice that
Typical error reasons:
This function works like
-
If the
Works like
+
If the option
If
Tries to rename the file
Reads and evaluates Erlang expressions, separated by '.' (or ',', a sequence of expressions is also an expression), from - the file. Returns one of the following:
+ the file. +Returns one of the following:
The file was read and evaluated.
The file is read and evaluated.
An error occurred when opening the file or reading it.
- See
An error occurred when interpreting the Erlang
- expressions in the file. Use
The encoding of of
The encoding of
The same as
Sends the file
Sends
The file used must be opened using the
If the OS used does not support
The option list can contain the following options:
+The chunk size used by the Erlang fallback to send + data. If using the fallback, set this to a value + that comfortably fits in the systems memory. Default is 20 MB.
Instructs the emulator to use the
Sets the current working directory of the file server to
The functions in the
The functions in the module
Typical error reasons are:
In a future release, a bad type for the +
In a future release, a bad type for argument
Makes sure that any buffers kept by the operating system +
Ensures that any buffers kept by the operating system (not by the Erlang runtime system) are written to disk. On some platforms, this function might have no effect.
-Typical error reasons are:
+A typical error reason is:
Makes sure that any buffers kept by the operating system - (not by the Erlang runtime system) are written to disk. In - many ways it resembles fsync but it does not update - some of the file's metadata such as the access time. On - some platforms this function has no effect.
-Applications that access databases or log files often write - a tiny data fragment (e.g., one line in a log file) and then - call fsync() immediately in order to ensure that the written - data is physically stored on the harddisk. Unfortunately, fsync() - will always initiate two write operations: one for the newly - written data and another one in order to update the modification - time stored in the inode. If the modification time is not a part - of the transaction concept, fdatasync() can be used to avoid - unnecessary inode disk write operations.
-Available only in some POSIX systems, this call results in a - call to fsync(), or has no effect in systems not implementing - the fdatasync() syscall.
-Truncates the file referenced by
Sends the file
Sends
The file used must be opened using the raw flag, and the process
- calling sendfile must be the controlling process of the socket.
- See
If the OS used does not support sendfile, an Erlang fallback - using file:read and gen_tcp:send is used.
-The option list can contain the following options:
-Writes
If the file is opened with
Typical error reasons are:
+If the file is opened with
Typical error reasons:
There is a no space left on the device.
+No space is left on the device.
Writes the contents of the iodata term
Typical error reasons are:
+Writes the contents of the
Typical error reasons:
A component of the file name does not exist.
+A component of the filename does not exist.
A component of the file name is not a directory. On some +
A component of the filename is not a directory. On some
platforms,
There is a no space left on the device.
+No space is left on the device.
Same as
Change file information. Returns
Changes file information. Returns
--include_lib("kernel/include/file.hrl").
- The time type set in
If the
The time type set in
Interprets the time set as local.
Interprets it as universal time.
Must be seconds since or before Unix time epoch, + which is 1970-01-01 00:00 UTC.
Default is
If the option
The following fields are used from the record, if they are - given.
+ specified:The last time the file was read.
The last time the file was written.
On Unix, any value give for this field will be ignored - (the "ctime" for the file will be set to the current +
On Unix, any value specified for this field is ignored + (the "ctime" for the file is set to the current time). On Windows, this field is the new creation time to set for the file.
The file permissions as the sum of the following bit values:
Read permission: owner
Write permission: owner
Execute permission: owner
Read permission: group
Write permission: group
Execute permission: group
Read permission: other
Write permission: other
Execute permission: other
Set user id on execution
Set group id on execution
On Unix platforms, other bits than those listed above - may be set.
+On Unix platforms, the following bits + can also be set.
Indicates the owner of the file. Ignored for non-Unix +
Indicates the file owner. Ignored for non-Unix file systems.
Gives the group that the owner of the file belongs to. +
Gives the group that the file owner belongs to. Ignored for non-Unix file systems.
A component of the file name is not a directory. On some +
A component of the filename is not a directory. On some
platforms,
Some operating system file operations, for example a
-
Some operating system file operations, for example, a
+
If the device driver thread pool is active, file operations are done through those threads instead, so the emulator can go on executing Erlang processes. Unfortunately, the time for serving a - file operation increases due to the extra scheduling required + file operation increases because of the extra scheduling required from the operating system.
If the device driver thread pool is disabled or of size 0, large
- file reads and writes are segmented into several smaller, which
- enables the emulator so server other processes during the file
- operation. This gives the same effect as when using the thread
+ file reads and writes are segmented into many smaller, which
+ enable the emulator to serve other processes during the file
+ operation. This has the same effect as when using the thread
pool, but with larger overhead. Other file operations, for
- example
For increased performance, raw files are recommended. Raw files - uses the file system of the node's host machine. For normal files - (non-raw), the file server is used to find the files, and if - the node is running its file server as slave to another node's, - and the other node runs on some other host machine, they may have - different file systems. This is seldom a problem, but you have - now been warned.
-A normal file is really a process so it can be used as an IO
- device (see
+ For normal files (non-raw), the file server is used to find the files, + and if the node is running its file server as slave to the file server + of another node, and the other node runs on some other host machine, + they can have different file systems. + However, this is seldom a problem.
+A normal file is really a process so it can be used as an I/O
+ device (see
+
Caching data to reduce the number of file operations, or rather - the number of calls to the file driver, will generally increase + the number of calls to the file driver, generally increases performance. The following function writes 4 MBytes in 23 seconds when tested:
create_file_slow(FD, M, N) ->
ok = file:write(FD, <>),
create_file_slow(FD, M+1, N).]]>
+
The following, functionally equivalent, function collects 1024
entries into a list of 128 32-byte binaries before each call to
-
= 0 ->
{ok, FD} = file:open(Name, [raw, write, delayed_write, binary]),
@@ -2055,61 +2205,62 @@ create_file(FD, M, N0, R) when M + 8 =< N0 ->
create_file(FD, M, N0, R) ->
N1 = N0-1,
create_file(FD, M, N1, [<> | R]).]]>
+
Trust only your own benchmarks. If the list length in
-
If the size of each binary is increased to 64 bytes, it will - also run slightly faster, but the code will be twice as clumsy. - In the current implementation are binaries larger than 64 bytes + something that this simple benchmark cannot predict.
+If the size of each binary is increased to 64 bytes, it + also runs slightly faster, but the code is then twice as clumsy. + In the current implementation, binaries larger than 64 bytes are stored in memory common to all processes and not copied when sent between processes, while these smaller binaries are stored on the process heap and copied when sent like any other term.
-So, with a binary size of 68 bytes
So, with a binary size of 68 bytes,
A raw file is really a port. When writing data to a port, it is
- efficient to write a list of binaries. There is no need to
+ efficient to write a list of binaries. It is not needed to
flatten a deep list before writing. On Unix hosts, scatter output,
which writes a set of buffers in one operation, is used when
- possible. In this way
For raw files,
The options
And, as a really bad example,
As a bad example,
If an error occurs when accessing an open file with the
If an error occurs when accessing an open file with module
+
The
This module provides functions for communicating with
sockets using the SCTP protocol. The implementation assumes that
the OS kernel supports SCTP
-
- This module was written for one-to-many style sockets
+
During development, this implementation was tested on:
+During OTP adaptation it was tested on:
+This module was written for one-to-many style sockets
(type
Record definitions for the
-include_lib("kernel/include/inet_sctp.hrl").
+ Record definitions for this module can be found using:
+
+-include_lib("kernel/include/inet_sctp.hrl").
These record definitions use the "new" spelling 'adaptation', not the deprecated 'adaption', regardless of which spelling the underlying C API uses.
One of the
-
One of the
+
Abnormally terminates the association given by
Abnormally terminates the association specified by
+
Completely closes the socket and all associations on it. The unsent
- data is flushed as in
Closes the socket and all associations on it. The unsent
+ data is flushed as in
Same as
Same as
Establishes a new association for the socket
WARNING:Using a value of
Establishes a new association for socket
Using a value of
#sctp_assoc_change{
- state = atom(),
- error = atom(),
- outbound_streams = integer(),
- inbound_streams = integer(),
- assoc_id = assoc_id()
- }
+ event that contains, in particular, the new
+
+#sctp_assoc_change{
+ state = atom(),
+ error = atom(),
+ outbound_streams = integer(),
+ inbound_streams = integer(),
+ assoc_id = assoc_id()
+}
The number of outbound and inbound streams can be set by
- giving an
connect(Socket, Ip, Port>,
- [{sctp_initmsg,#sctp_initmsg{num_ostreams=OutStreams,
- max_instreams=MaxInStreams}}])
+ giving an
+connect(Socket, Ip, Port>,
+ [{sctp_initmsg,#sctp_initmsg{num_ostreams=OutStreams,
+ max_instreams=MaxInStreams}}])
All options
The returned
The following values of
All other states do not normally occur in the output from
-
Association is successfully established. This
+ indicates a successful completion of
The association cannot be established
+ (
Other states do not normally occur in the output from
+
Field
Same as
Same as
Initiates a new association for the socket
Initiates a new association for socket
The fundamental difference between this API
- and
The parameters are as described
- in
The timer associated with
The fundamental difference between this API
+ and
The parameters are as described in
+
The timer associated with
Assigns a new controlling process
Assigns a new controlling process
Gracefully terminates the association given by
Gracefully terminates the association specified by
+
Translates an SCTP error number from, for example,
+
Sets up a socket to listen on the IP address and port number - it is bound to.
-For type
For type
For type
For type
Creates an SCTP socket and binds it to the local addresses
- specified by all
Creates an SCTP socket and binds it to the local addresses
+ specified by all
Other options are:
+ free port. +Other options:
Set up the socket for IPv6.
+Sets up the socket for IPv6.
Set up the socket for IPv4. This is the default.
+Sets up the socket for IPv4. This is the default.
A default set of socket
- Branch off an existing association
- The existing association argument
Branches off an existing association
The existing association argument
Receives the
Receives the
The actual
The
Possible SCTP events:
#sctp_paddr_change{
- addr = {ip_address(),port()},
- state = atom(),
- error = integer(),
- assoc_id = assoc_id()
- }
- Indicates change of the status of the peer's IP address given by
-
+#sctp_paddr_change{
+ addr = {ip_address(),port()},
+ state = atom(),
+ error = integer(),
+ assoc_id = assoc_id()
+}
+ Indicates change of the status of the IP address of the peer
+ specified by
+
In case of an error (for example,
+#sctp_send_failed{
+ flags = true | false,
+ error = integer(),
+ info = #sctp_sndrcvinfo{},
+ assoc_id = assoc_id()
+ data = binary()
+}
+ The sender can receive this event if a send operation fails.
+A Boolean specifying if the data has been transmitted + over the wire.
Provides extended diagnostics, use
+
The original
+
The whole original data chunk attempted to be sent.
In case of an error (e.g.
#sctp_send_failed{
- flags = true | false,
- error = integer(),
- info = #sctp_sndrcvinfo{},
- assoc_id = assoc_id()
- data = binary()
- }
- The sender may receive this event if a send operation fails.
- The
In the current implementation of the Erlang/SCTP binding,
- this Event is internally converted into an
#sctp_adaptation_event{
- adaptation_ind = integer(),
- assoc_id = assoc_id()
- }
- Delivered when a peer sends an Adaptation Layer Indication
- parameter (configured through the option
-
+#sctp_adaptation_event{
+ adaptation_ind = integer(),
+ assoc_id = assoc_id()
+}
+ Delivered when a peer sends an adaptation layer indication
+ parameter (configured through option
+
#sctp_pdapi_event{
- indication = sctp_partial_delivery_aborted,
- assoc_id = assoc_id()
- }
+
+#sctp_pdapi_event{
+ indication = sctp_partial_delivery_aborted,
+ assoc_id = assoc_id()
+}
A partial delivery failure. In the current implementation of
- the Erlang/SCTP binding, this Event is internally converted
- into an
Sends the
Sends the
Sends
Translates an SCTP error number from for example
-
Sends a
The set of admissible SCTP socket options is by construction
- orthogonal to the sets of TCP, UDP and generic INET options:
- only those options which are explicitly listed below are allowed
+ orthogonal to the sets of TCP, UDP, and generic
Determines the type of data returned from
Determines the type of data returned from
+
If
If
NB: This can cause the message queue to overflow, +
Notice that this can cause the message queue to overflow, as there is no way to throttle the sender in this case - (no flow control!).
+ (no flow control).If
If
Sets the Type-Of-Service field on the IP datagrams being sent, - to the given value, which effectively determines a prioritization +
Sets the Type-Of-Service field on the IP datagrams that are sent, + to the specified value. This effectively determines a prioritization policy for the outbound packets. The acceptable values - are system-dependent. TODO: we do not provide - symbolic names for these values yet.
+ are system-dependent.A protocol-independent equivalent of
By default
Defaults to
By default
Defaults to
The size, in bytes, of the *kernel* send buffer for this socket. +
The size, in bytes, of the OS kernel send buffer for this socket.
Sending errors would occur for datagrams larger than
The size, in bytes, of the *kernel* recv buffer for this socket. +
The size, in bytes, of the OS kernel receive buffer for this socket.
Sending errors would occur for datagrams larger than
-
- Override which callback module is used. Defaults to
-
Overrides which callback module is used. Defaults to
+
#sctp_rtoinfo{
- assoc_id = assoc_id(),
- initial = integer(),
- max = integer(),
- min = integer()
- }
- Determines re-transmission time-out parameters, in milliseconds,
- for the association(s) given by
+#sctp_rtoinfo{
+ assoc_id = assoc_id(),
+ initial = integer(),
+ max = integer(),
+ min = integer()
+}
+ Determines retransmission time-out parameters, in milliseconds,
+ for the association(s) specified by
#sctp_assocparams{
- assoc_id = assoc_id(),
- asocmaxrxt = integer(),
- number_peer_destinations = integer(),
- peer_rwnd = integer(),
- local_rwnd = integer(),
- cookie_life = integer()
- }
- Determines association parameters for the association(s) given by
-
+#sctp_assocparams{
+ assoc_id = assoc_id(),
+ asocmaxrxt = integer(),
+ number_peer_destinations = integer(),
+ peer_rwnd = integer(),
+ local_rwnd = integer(),
+ cookie_life = integer()
+}
+ Determines association parameters for the association(s) specified by
+
#sctp_initmsg{
- num_ostreams = integer(),
- max_instreams = integer(),
- max_attempts = integer(),
- max_init_timeo = integer()
- }
- Determines the default parameters which this socket attempts +
+#sctp_initmsg{
+ num_ostreams = integer(),
+ max_instreams = integer(),
+ max_attempts = integer(),
+ max_init_timeo = integer()
+}
+ Determines the default parameters that this socket tries
to negotiate with its peer while establishing an association with it.
- Should be set after
Determines the time (in seconds) after which an idle association is +
Determines the time, in seconds, after which an idle association is
automatically closed.
Turns on|off the Nagle algorithm for merging small packets - into larger ones (which improves throughput at the expense - of latency).
+ into larger ones. This improves throughput at the expense + of latency.If
Turns on|off automatic mapping of IPv4 addresses into IPv6 ones - (if the socket address family is AF_INET6).
+ (if the socket address family is #sctp_prim{
- assoc_id = assoc_id(),
- addr = {IP, Port}
- }
- IP = ip_address()
- Port = port_number()
- For the association given by
+#sctp_prim{
+ assoc_id = assoc_id(),
+ addr = {IP, Port}
+}
+ IP = ip_address()
+ Port = port_number()
+ For the association specified by
#sctp_setpeerprim{
- assoc_id = assoc_id(),
- addr = {IP, Port}
- }
- IP = ip_address()
- Port = port_number()
- When set, informs the peer that it should use
+#sctp_setpeerprim{
+ assoc_id = assoc_id(),
+ addr = {IP, Port}
+}
+ IP = ip_address()
+ Port = port_number()
+ When set, informs the peer to use
#sctp_setadaptation{
- adaptation_ind = integer()
- }
- When set, requests that the local endpoint uses the value given by
-
+#sctp_setadaptation{
+ adaptation_ind = integer()
+}
+ When set, requests that the local endpoint uses the value specified
+ by
#sctp_paddrparams{
- assoc_id = assoc_id(),
- address = {IP, Port},
- hbinterval = integer(),
- pathmaxrxt = integer(),
- pathmtu = integer(),
- sackdelay = integer(),
- flags = list()
- }
- IP = ip_address()
- Port = port_number()
- This option determines various per-address parameters for
- the association given by
+#sctp_paddrparams{
+ assoc_id = assoc_id(),
+ address = {IP, Port},
+ hbinterval = integer(),
+ pathmaxrxt = integer(),
+ pathmtu = integer(),
+ sackdelay = integer(),
+ flags = list()
+}
+IP = ip_address()
+Port = port_number()
+ Determines various per-address parameters for
+ the association specified by
Heartbeat interval, in milliseconds
Maximum number of retransmissions before this address is + considered unreachable (and an alternative address is selected)
Fixed Path MTU, if automatic discovery is disabled (see
+
Delay, in milliseconds, for SAC messages (if the delay is
+ enabled, see
The following flags are available:
+ #sctp_sndrcvinfo{
- stream = integer(),
- ssn = integer(),
- flags = list(),
- ppid = integer(),
- context = integer(),
- timetolive = integer(),
- tsn = integer(),
- cumtsn = integer(),
- assoc_id = assoc_id()
- }
+
+#sctp_sndrcvinfo{
+ stream = integer(),
+ ssn = integer(),
+ flags = list(),
+ ppid = integer(),
+ context = integer(),
+ timetolive = integer(),
+ tsn = integer(),
+ cumtsn = integer(),
+ assoc_id = assoc_id()
+}
Other fields are rarely used. See
-
The following fields typically must be specified by the sender:
+Stream number (0-base) within the association + to send the messages through;
The following flags are recognised:
+Other fields are rarely used. For complete information, see
+
#sctp_event_subscribe{
- data_io_event = true | false,
- association_event = true | false,
- address_event = true | false,
- send_failure_event = true | false,
- peer_error_event = true | false,
- shutdown_event = true | false,
- partial_delivery_event = true | false,
- adaptation_layer_event = true | false
- }
+
+#sctp_event_subscribe{
+ data_io_event = true | false,
+ association_event = true | false,
+ address_event = true | false,
+ send_failure_event = true | false,
+ peer_error_event = true | false,
+ shutdown_event = true | false,
+ partial_delivery_event = true | false,
+ adaptation_layer_event = true | false
+}
This option determines which
#sctp_assoc_value{
- assoc_id = assoc_id(),
- assoc_value = integer()
- }
+
+#sctp_assoc_value{
+ assoc_id = assoc_id(),
+ assoc_value = integer()
+}
Rarely used. Determines the ACK time
- (given by
#sctp_status{
- assoc_id = assoc_id(),
- state = atom(),
- rwnd = integer(),
- unackdata = integer(),
- penddata = integer(),
- instrms = integer(),
- outstrms = integer(),
- fragmentation_point = integer(),
- primary = #sctp_paddrinfo{}
- }
+
+#sctp_status{
+ assoc_id = assoc_id(),
+ state = atom(),
+ rwnd = integer(),
+ unackdata = integer(),
+ penddata = integer(),
+ instrms = integer(),
+ outstrms = integer(),
+ fragmentation_point = integer(),
+ primary = #sctp_paddrinfo{}
+}
This option is read-only. It determines the status of
- the SCTP association given by
The semantics of other fields is the following:
-Semantics of the other fields:
+ #sctp_paddrinfo{
- assoc_id = assoc_id(),
- address = {IP, Port},
- state = inactive | active | unconfirmed,
- cwnd = integer(),
- srtt = integer(),
- rto = integer(),
- mtu = integer()
- }
- IP = ip_address()
- Port = port_number()
+
+#sctp_paddrinfo{
+ assoc_id = assoc_id(),
+ address = {IP, Port},
+ state = inactive | active | unconfirmed,
+ cwnd = integer(),
+ srtt = integer(),
+ rto = integer(),
+ mtu = integer()
+}
+IP = ip_address()
+Port = port_number()
This option is read-only. It determines the parameters specific to
- the peer's address given by
Example of an Erlang SCTP Server which receives SCTP messages and - prints them on the standard output:
- -module(sctp_server).
-
- -export([server/0,server/1,server/2]).
- -include_lib("kernel/include/inet.hrl").
- -include_lib("kernel/include/inet_sctp.hrl").
-
- server() ->
- server(any, 2006).
-
- server([Host,Port]) when is_list(Host), is_list(Port) ->
- {ok, #hostent{h_addr_list = [IP|_]}} = inet:gethostbyname(Host),
- io:format("~w -> ~w~n", [Host, IP]),
- server([IP, list_to_integer(Port)]).
-
- server(IP, Port) when is_tuple(IP) orelse IP == any orelse IP == loopback,
- is_integer(Port) ->
- {ok,S} = gen_sctp:open(Port, [{recbuf,65536}, {ip,IP}]),
- io:format("Listening on ~w:~w. ~w~n", [IP,Port,S]),
- ok = gen_sctp:listen(S, true),
- server_loop(S).
-
- server_loop(S) ->
- case gen_sctp:recv(S) of
- {error, Error} ->
- io:format("SCTP RECV ERROR: ~p~n", [Error]);
- Data ->
- io:format("Received: ~p~n", [Data])
- end,
- server_loop(S).
- Example of an Erlang SCTP Client which interacts with the above Server.
- Note that in this example, the Client creates an association with
- the Server with 5 outbound streams. For this reason, sending of
- "Test 0" over Stream 0 succeeds, but sending of "Test 5"
- over Stream 5 fails. The client then
-module(sctp_client).
-
- -export([client/0, client/1, client/2]).
- -include_lib("kernel/include/inet.hrl").
- -include_lib("kernel/include/inet_sctp.hrl").
+ SCTP Examples
+ Example of an Erlang SCTP server that receives SCTP messages and
+ prints them on the standard output:
+
+-module(sctp_server).
+
+-export([server/0,server/1,server/2]).
+-include_lib("kernel/include/inet.hrl").
+-include_lib("kernel/include/inet_sctp.hrl").
+
+server() ->
+ server(any, 2006).
+
+server([Host,Port]) when is_list(Host), is_list(Port) ->
+ {ok, #hostent{h_addr_list = [IP|_]}} = inet:gethostbyname(Host),
+ io:format("~w -> ~w~n", [Host, IP]),
+ server([IP, list_to_integer(Port)]).
+
+server(IP, Port) when is_tuple(IP) orelse IP == any orelse IP == loopback,
+ is_integer(Port) ->
+ {ok,S} = gen_sctp:open(Port, [{recbuf,65536}, {ip,IP}]),
+ io:format("Listening on ~w:~w. ~w~n", [IP,Port,S]),
+ ok = gen_sctp:listen(S, true),
+ server_loop(S).
+
+server_loop(S) ->
+ case gen_sctp:recv(S) of
+ {error, Error} ->
+ io:format("SCTP RECV ERROR: ~p~n", [Error]);
+ Data ->
+ io:format("Received: ~p~n", [Data])
+ end,
+ server_loop(S).
+ Example of an Erlang SCTP client interacting with the above server.
+ Notice that in this example the client creates an association with
+ the server with 5 outbound streams. Therefore, sending of
+ "Test 0" over stream 0 succeeds, but sending of "Test 5"
+ over stream 5 fails. The client then abort s the association,
+ which results in that the corresponding event is received on
+ the server side.
+
+-module(sctp_client).
+
+-export([client/0, client/1, client/2]).
+-include_lib("kernel/include/inet.hrl").
+-include_lib("kernel/include/inet_sctp.hrl").
+
+client() ->
+ client([localhost]).
+
+client([Host]) ->
+ client(Host, 2006);
- client() ->
- client([localhost]).
-
- client([Host]) ->
- client(Host, 2006);
-
- client([Host, Port]) when is_list(Host), is_list(Port) ->
- client(Host,list_to_integer(Port)),
- init:stop().
-
- client(Host, Port) when is_integer(Port) ->
- {ok,S} = gen_sctp:open(),
- {ok,Assoc} = gen_sctp:connect
- (S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]),
- io:format("Connection Successful, Assoc=~p~n", [Assoc]),
-
- io:write(gen_sctp:send(S, Assoc, 0, <<"Test 0">>)),
- io:nl(),
- timer:sleep(10000),
- io:write(gen_sctp:send(S, Assoc, 5, <<"Test 5">>)),
- io:nl(),
- timer:sleep(10000),
- io:write(gen_sctp:abort(S, Assoc)),
- io:nl(),
-
- timer:sleep(1000),
- gen_sctp:close(S).
- A very simple Erlang SCTP Client which uses the - connect_init API.
--module(ex3).
+client([Host, Port]) when is_list(Host), is_list(Port) ->
+ client(Host,list_to_integer(Port)),
+ init:stop().
+
+client(Host, Port) when is_integer(Port) ->
+ {ok,S} = gen_sctp:open(),
+ {ok,Assoc} = gen_sctp:connect
+ (S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]),
+ io:format("Connection Successful, Assoc=~p~n", [Assoc]),
+
+ io:write(gen_sctp:send(S, Assoc, 0, <<"Test 0">>)),
+ io:nl(),
+ timer:sleep(10000),
+ io:write(gen_sctp:send(S, Assoc, 5, <<"Test 5">>)),
+ io:nl(),
+ timer:sleep(10000),
+ io:write(gen_sctp:abort(S, Assoc)),
+ io:nl(),
+
+ timer:sleep(1000),
+ gen_sctp:close(S).
+ A simple Erlang SCTP client that uses the
+-module(ex3).
-export([client/4]).
-include_lib("kernel/include/inet.hrl").
@@ -1099,7 +1104,7 @@ client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) ->
io:format("Association 2 connect result: ~p. AssocId: ~p~n",
[SAC#sctp_assoc_change.state, SAC#sctp_assoc_change.assoc_id]),
client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2,
- SAC#sctp_assoc_change.assoc_id);
+ SAC#sctp_assoc_change.assoc_id);
{sctp, S, Peer1, Port1, Data} ->
io:format("Association 1: received ~p~n", [Data]),
@@ -1118,20 +1123,19 @@ client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) ->
after 5000 ->
ok
- end.
-
- The
This module provides functions for communicating with sockets using the TCP/IP protocol.
-The following code fragment provides a simple example of +
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:
+ binary, and closing the connection:
client() ->
SomeHostInNet = "localhost", % to make it runnable on one machine
@@ -43,8 +42,8 @@ client() ->
[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:
+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},
@@ -61,7 +60,8 @@ do_recv(Sock, Bs) ->
{error, closed} ->
{ok, list_to_binary(Bs)}
end.
- For more examples, see the
For more examples, see section
+
Accepts an incoming connection request on a listening socket.
+
Returns:
+A POSIX error value if something else goes wrong, see
+
Packets can be sent to the returned socket
+{tcp, Socket, Data}
+ The
Closes a TCP socket.
+Connects to a server on TCP port
The available options are:
+ with IP addressThe following options are available:
If the host has several network interfaces, this option - specifies which one to use.
+If the host has many network interfaces, this option + specifies which one to use.
Same as
Same as
If a socket has somehow been connected without using
-
If a socket has somehow been connected without using
+
Set up the socket for IPv4.
-Set up the socket for IPv6.
-Sets up the socket for IPv4.
Sets up the socket for IPv6.
Specify which local port number to use.
-
- Override which callback module is used. Defaults to
-
Specifies which local port number to use.
Overrides which callback module is used. Defaults to
+
See
-
See
+
Packets can be sent to the returned socket
{tcp, Socket, Data}
- If the socket is in
If the socket is in
{tcp_passive, Socket}
If the socket is closed, the following message is delivered:
{tcp_closed, Socket}
- If an error occurs on the socket, the following message is - delivered:
+If an error occurs on the socket, the following message is delivered
+ (unless
{tcp_error, Socket, Reason}
- unless
The optional
The optional
The default values for options given to
The default values for options specified to
Assigns a new controlling process
Sets up a socket to listen on the port
Sets up a socket to listen on port
If
The available options are:
+If
The following options are available:
Received
Received
Received
Received
If the host has several network interfaces, this option - specifies which one to listen on.
-If the host has many network interfaces, this option + specifies which one to listen on.
Specify which local port number to use.
-Specifies which local port number to use.
If a socket has somehow been connected without using
-
If a socket has somehow been connected without using
+
Same as
Same as
Set up the socket for IPv6.
-Sets up the socket for IPv6.
Set up the socket for IPv4.
-
- Override which callback module is used. Defaults to
-
Sets up the socket for IPv4.
Overrides which callback module is used. Defaults to
+
See
-
See
+
The returned socket
The returned socket
The default values for options given to
The default values for options specified to
Accepts an incoming connection request on a listen socket.
-
Returns
Packets can be sent to the returned socket
-{tcp, Socket, Data}
- unless
It is worth noting that the
Sends a packet on a socket.
-There is no
This function receives a packet from a socket in passive - mode. A closed socket is indicated by a return value +
Receives a packet from a socket in passive
+ mode. A closed socket is indicated by return value
The
Argument
The optional
Assigns a new controlling process
The optional
Closes a TCP socket.
+Sends a packet on a socket.
+There is no
Close a socket in one or two directions.
-If
Closes a socket in one or two directions.
+If
If there is data buffered in the socket port, then the attempt +
If there is data buffered in the socket port, the attempt
to shutdown the socket is postponed until that data is written to the
- kernel socket send buffer. Any errors encountered will result
- in the socket being closed and
To be able to handle that the peer has done a shutdown on
- the write side, the
Option
The following example illustrates usage of the {active,once}
- option and multiple accepts by implementing a server as a
- number of worker processes doing accept on one single listen
- socket. The start/2 function takes the number of worker
- processes as well as a port number to listen for incoming
- connections on. If
The following example illustrates use of option
+
start(Num,LPort) ->
case gen_tcp:listen(LPort,[{active, false},{packet,2}]) of
@@ -421,7 +393,7 @@ loop(S) ->
io:format("Socket ~w closed [~w]~n",[S,self()]),
ok
end.
- A simple client could look like this:
+Example of a simple client:
client(PortNo,Message) ->
{ok,Sock} = gen_tcp:connect("localhost",PortNo,[{active,false},
@@ -430,30 +402,29 @@ client(PortNo,Message) ->
A = gen_tcp:recv(Sock,0),
gen_tcp:close(Sock),
A.
- The fact that the
The
Consider a process that receives data from a client process that
- is to be forwarded to a server on the network. The process has
- connected to the server via TCP/IP and does not get any acknowledge
- for each message it sends, but has to rely on the send timeout
- option to detect that the other end is unresponsive. We could use
- the
Consider a process that receives data from a client process
+ to be forwarded to a server on the network. The process is
+ connected to the server through TCP/IP and does not get any acknowledge
+ for each message it sends, but has to rely on the send time-out
+ option to detect that the other end is unresponsive. Option
+
- ...
- {ok,Sock} = gen_tcp:connect(HostAddress, Port,
- [{active,false},
- {send_timeout, 5000},
- {packet,2}]),
- loop(Sock), % See below
- ...
- In the loop where requests are handled, we can now detect send - timeouts:
+... +{ok,Sock} = gen_tcp:connect(HostAddress, Port, + [{active,false}, + {send_timeout, 5000}, + {packet,2}]), + loop(Sock), % See below +... +In the loop where requests are handled, send time-outs can now be + detected:
loop(Sock) ->
receive
@@ -477,11 +448,11 @@ loop(Sock) ->
Client ! {self(), data_sent},
loop(Sock)
end
- end.
- Usually it would suffice to detect timeouts on receive, as most + end. +
Usually it suffices to detect time-outs on receive, as most
protocols include some sort of acknowledgment from the server,
- but if the protocol is strictly one way, the
The
This module provides functions for communicating with sockets using the UDP protocol.
As returned by
+
Closes a UDP socket.
+Assigns a new controlling process
Associates a UDP port number (
The available options are:
+Associates a UDP port number (
The following options are available:
Received
Received
Received
Received
If the host has several network interfaces, this option - specifies which one to use.
-Same as
If the host has many network interfaces, this option + specifies which one to use.
Same as
If a socket has somehow been opened without using
-
If a socket has somehow been opened without using
+
Set up the socket for IPv6.
-Sets up the socket for IPv6.
Set up the socket for IPv4.
-
- Override which callback module is used. Defaults to
-
Sets up the socket for IPv4.
Overrides which callback module is used. Defaults to
+
Set the local device for a multicast socket.
-Sets the local device for a multicast socket.
- When
When
- The
- Datagrams with a TTL of 1 are not forwarded beyond the local
- network.
-
Default: 1
-
Join a multicast group.
-Leave multicast group.
-Option
Datagrams with a TTL of 1 are not forwarded beyond the local
+ network. Defaults to
Joins a multicast group.
Leaves a multicast group.
See
-
See
+
The returned socket
{udp, Socket, IP, InPortNo, Packet}
If the socket is not in an active mode, data can be
- retrieved via the
When a socket in
When a socket in
{udp_passive, Socket}
Default value for the receive buffer option is
If
Sends a packet to the specified address and port.
- The
If
This function receives a packet from a socket in passive - mode.
-The optional
Assigns a new controlling process
Receives a packet from a socket in passive mode. Optional parameter
+
Closes a UDP socket.
+Sends a packet to the specified address and port. Argument
+
This documentation describes the Global module which consists - of the following functionalities:
- +This module consists of the following services:
These services are controlled via the process
-
These services are controlled through the process
+
The ability to globally register names is a central concept in
the programming of distributed Erlang systems. In this module,
the equivalent of the
The registered names are stored in replica global name tables on every node. There is no central storage point. Thus, the translation of a name to a pid is fast, as it is always done - locally. When any action in taken which results in a change to - the global name table, all tables on other nodes are automatically - updated.
- + locally. For any action resulting in a change to the global name table, + all tables on other nodes are automatically updated.Global locks have lock identities and are set on a specific - resource. For instance, the specified resource could be a pid. + resource. For example, the specified resource can be a pid. When a global lock is set, access to the locked resource is - denied for all other resources other than the lock requester.
- -Both the registration and lock functionalities are atomic. All - nodes involved in these actions will have the same view of + denied for all resources other than the lock requester.
+Both the registration and lock services are atomic. + All nodes involved in these actions have the same view of the information.
-The global name server also performs the critical task of
- continuously monitoring changes in node configuration: if a node
- which runs a globally registered process goes down, the name
- will be globally unregistered. To this end the global name
+ continuously monitoring changes in node configuration. If a node
+ that runs a globally registered process goes down, the name
+ is globally unregistered. To this end, the global name
server subscribes to
The name server will also maintain a fully connected network. For
+
The name server also maintains a fully connected network. For
example, if node
If the global name server fails to connect nodes (
If the fully connected network is not set up properly, the
- first thing to try is to increase the value of
-
If the fully connected network is not set up properly, try
+ first to increase the value of
Deletes the lock
This function can be used as a name resolving function for
-
Can be used as a name resolving function for
+
The function unregisters both pids and sends the message
This function can be used as a name resolving function for
-
Can be used as a name resolving function for
+
The function randomly selects one of the pids for registration and + kills the other one.
This function can be used as a name resolving function for
-
Can be used as a name resolving function for
+
The function randomly selects one of the pids for registration, and
+ sends the message
Atomically changes the registered name
Function
Globally associates the name
Globally associates name
When new nodes are added to the network, they are informed
of the globally registered names that already exist.
The network is also informed of any global names in newly
connected nodes. If any name clashes are discovered,
- the
If you plan to change code without restarting your system,
you must use an external fun (
There are three pre-defined resolve functions: +
Three predefined resolve functions exist:
This function is completely synchronous. This means that +
This function is completely synchronous, that is, when this function returns, the name is either registered on all nodes or none.
-The function returns
Releases up to and including OTP R10 did not check if the - process was already registered. As a consequence the - global name table could become inconsistent. The old +
Releases up to and including Erlang/OTP R10 did not check if the
+ process was already registered. The global name table could
+ therefore become inconsistent. The old
(buggy) behavior can be chosen by giving the Kernel
application variable
If a process with a registered name dies, or the node goes down, the name is unregistered on all nodes.
Returns a lists of all globally registered names.
-Atomically changes the registered name
The
Returns a list of all globally registered names.
Sends the message
Sends message
Failure: If
If
If no value for
If no value for
This function is completely synchronous.
- -If a process which holds a lock dies, or the node goes +
If a process that holds a lock dies, or the node goes down, the locks held by the process are deleted.
-The global name server keeps track of all processes sharing the same lock, that is, if two processes set the same lock, both processes must delete the lock.
-This function does not address the problem of a deadlock. A deadlock can never occur as long as processes only lock one - resource at a time. But if some processes try to lock two or - more resources, a deadlock may occur. It is up to the + resource at a time. A deadlock can occur if some processes + try to lock two or more resources. It is up to the application to detect and rectify a deadlock.
-Some values of
Avoid the following values of
Synchronizes the global name server with all nodes known to
- this node. These are the nodes which are returned from
+ this node. These are the nodes that are returned from
The only possible error reason Sets a lock on Sets a lock on
Removes the globally registered name
Returns the pid with the globally registered name
The global group function makes it possible to group the nodes
- in a system into partitions, each partition having its own global
- name space, refer to
The main advantage of dividing systems to global groups is that +
This module makes it possible to partition the nodes of a
+ system into global groups. Each global group has its own
+ global namespace, see
The main advantage of dividing systems into global groups is that the background load decreases while the number of nodes to be updated is reduced when manipulating globally registered names.
The Kernel configuration parameter
{global_groups, [GroupTuple :: group_tuple()]}
For the processes and nodes to run smoothly using the global
@@ -54,22 +54,24 @@
All involved nodes must agree on the global group definition,
- or the behavior of the system is undefined.
All nodes in the system should belong to exactly +
All nodes in the system must belong to exactly one global group.
In the following description, a group node is a node +
In the following descriptions, a group node is a node belonging to the same global group as the local node.
A
A node started with the command line flag
A node started with command-line flag
A global group defined with
A global group defined with
A registered name.
Returns a tuple containing the name of the global group +
Returns a tuple containing the name of the global group that
the local node belongs to, and the list of all other known
group names. Returns
Returns a list containing information about the global - groups. Each element of the list is a tuple. The order of - the tuples is not defined.
+ groups. Each list element is a tuple. The order of + the tuples is undefined.If the local node is part of a global group,
-
A list of pids, specifying the processes which have +
A list of pids, specifying the processes that have
subscribed to
Depending on
A process which has subscribed will receive the messages +
Depending on
A process that has subscribed receives the messages
Returns the names of all group nodes, regardless of their current status.
Returns a list of all names which are globally registered +
Returns a list of all names that are globally registered on the specified node or in the specified global group.
Searches for
If
If
Synchronizes the group nodes, that is, the global name - servers on the group nodes. Also check the names globally + servers on the group nodes. Also checks the names globally registered in the current global group and unregisters them on any known node not part of the group.
If synchronization is not possible, an error report is sent
- to the error logger (see also
Failure:
-
Returns
Searches for
If
If
In the situation where a node has lost its connections to other - nodes in its global group, but has connections to nodes in other - global groups, a request from another global group may produce an - incorrect or misleading result. For example, the isolated node may - not have accurate information about registered names in its - global group.
-Note also that the
Distribution of applications is highly dependent of the global - group definitions. It is not recommended that an application is - distributed over several global groups of the obvious reason that - the registered names may be moved to another global group at - failover/takeover. There is nothing preventing doing this, but - the application code must in such case handle the situation.
+In the situation where a node has lost its connections to other + nodes in its global group, but has connections to nodes in other + global groups, a request from another global group can produce an + incorrect or misleading result. For example, the isolated node can + have inaccurate information about registered names in its + global group.
Function
+
Distribution of applications is highly dependent of the global + group definitions. It is not recommended that an application is + distributed over many global groups, as + the registered names can be moved to another global group at + failover/takeover. Nothing prevents this to be done, but + the application code must then handle the situation.
This modules contains the interface to the
An Erlang runtime system to be monitored by a heart program,
- should be started with the command line flag
An Erlang runtime system to be monitored by a heart program
+ is to be started with command-line flag
% erl -heart ...-
If the system should be rebooted because of missing heart-beats,
- or a terminated Erlang runtime system, the environment variable
-
To reboot on the WINDOWS platform
If the system is to be rebooted because of missing heartbeats,
+ or a terminated Erlang runtime system, environment variable
+
To reboot on Windows,
The hardware watchdog will not be started under Solaris if
- the environment variable
The
The hardware watchdog is not started under Solaris if
+ environment variable
The environment variables
% erl -heart -env HEART_BEAT_TIMEOUT 30 ...
The value (in seconds) must be in the range 10 < X <= 65535.
-It should be noted that if the system clock is adjusted with
- more than
If a crash occurs, an
Notice that if the system clock is adjusted with
+ more than
If a crash occurs, an
% erl -heart -env ERL_CRASH_DUMP_SECONDS 10 ...- -
If a regular core dump is wanted, let heart know by setting the kill signal to abort
- using the environment variable
If a regular core dump is wanted, let
% erl -heart -env HEART_KILL_SIGNAL SIGABRT ...- -
- Furthermore,
- Suppresses the writing a crash dump file entirely, - thus rebooting the runtime system immediately. - This is the same as not setting the environment variable. -
-Setting the environment variable to a negative value will not reboot - the runtime system until the crash dump file has been completly written. -
-
- Heart will wait for
In the following descriptions, all function fails with reason +
Furthermore,
Suppresses the writing of a crash dump file entirely, + thus rebooting the runtime system immediately. + This is the same as not setting the environment variable.
+Setting the environment variable to a negative value does not + reboot the runtime system until the crash dump file is completly + written.
+In the following descriptions, all functions fail with reason
Sets a temporary reboot command. This command is used if +
Sets a temporary reboot command. This command is used if
a
Limitations: The
Limitations: Command string
Clears the temporary boot command. If the system terminates,
the normal
Get the temporary reboot command. If the command is cleared, - the empty string will be returned.
+Gets the temporary reboot command. If the command is cleared, + the empty string is returned.
This validation callback will be executed before any heartbeat sent
- to the port program. For the validation to succeed it needs to return
- with the value
This validation callback will be executed before any
+ heartbeat is sent to the port program. For the validation to
+ succeed it needs to return with the value
An exception within the callback will be treated as a validation failure.
-The callback will be removed if the system reboots.
+An exception within the callback will be treated as a validation failure.
+The callback will be removed if the system reboots.
Provides access to TCP/IP protocols.
-See also ERTS User's Guide, Inet configuration for more - information on how to configure an Erlang runtime system for IP - communication.
-Two Kernel configuration parameters affect the behaviour of all
- sockets opened on an Erlang node:
-
This module provides access to TCP/IP protocols.
+See also
+
The following two
When
Using the Kernel configuration parameters mentioned above, one
- can set default options for all TCP sockets on a node. This should
- be used with care, but options like
Using the
$ erl -sname test -kernel \
inet_default_connect_options '[{delay_send,true}]' \
inet_default_listen_options '[{delay_send,true}]'
- Note that the default option
Notice that default option
Addresses as inputs to functions can be either a string or a
- tuple. For instance, the IP address 150.236.20.73 can be passed to
-
IPv4 address examples:
+ tuple. For example, the IP address 150.236.20.73 can be passed to +IPv4 address examples:
Address ip_address()
------- ------------
127.0.0.1 {127,0,0,1}
192.168.42.2 {192,168,42,2}
- IPv6 address examples:
+IPv6 address examples:
Address ip_address()
------- ------------
@@ -77,7 +81,9 @@ FFFF::192.168.42.2
{16#3ffe,16#b80,16#1f8d,16#2,16#204,16#acff,16#fe17,16#bf38}
fe80::204:acff:fe17:bf38
{16#fe80,0,0,0,0,16#204,16#acff,16#fe17,16#bf38}
- A function that may be useful is
Function
+
1> inet:parse_address("192.168.42.2").
{ok,{192,168,42,2}}
@@ -89,9 +95,12 @@ fe80::204:acff:fe17:bf38
- The record is defined in the Kernel include file "inet.hrl".
- Add the following directive to the module:
--include_lib("kernel/include/inet.hrl").
+ The record is defined in the Kernel include file
+ "inet.hrl" .
+ Add the following directive to the module:
+
+-include_lib("kernel/include/inet.hrl").
+
@@ -110,17 +119,20 @@ fe80::204:acff:fe17:bf38
- An atom which is named from the Posix error codes
- used in Unix, and in the runtime libraries of most
- C compilers. See
+
+ An atom that is named from the POSIX error codes used in Unix,
+ and in the runtime libraries of most C compilers. See section
POSIX Error Codes .
socket()
-
- See gen_tcp(3)
- and gen_udp(3) .
+
+ See
+ gen_tcp:type-socket
+ and
+ gen_udp:type-socket .
+
@@ -131,443 +143,415 @@ fe80::204:acff:fe17:bf38
- Close a socket of any type
+ Close a socket of any type.
Closes a socket of any type.
+
-
- Return a list of IP configuration parameters
+
+ Return a descriptive string for an error reason.
- Returns the state of the Inet configuration database in
- form of a list of recorded configuration parameters. (See the
- ERTS User's Guide, Inet configuration, for more information).
- Only parameters with other than default values are returned.
+ Returns a diagnostic error string. For possible POSIX values and
+ corresponding strings, see section
+ POSIX Error Codes .
+
-
- Return a descriptive string for an error reason
+
+ Return a list of IP configuration parameters.
- Returns a diagnostic error string. See the section below
- for possible Posix values and the corresponding
- strings.
+ Returns the state of the Inet configuration database in
+ form of a list of recorded configuration parameters. For more
+ information, see ERTS User's Guide:
+ Inet Configuration .
+ Only parameters with other than default values are returned.
+
- Return the IP-address for a host
+ Return the IP address for a host.
- Returns the IP-address for Host as a tuple of
- integers. Host can be an IP-address, a single hostname
- or a fully qualified hostname.
+ Returns the IP address for Host as a tuple of
+ integers. Host can be an IP address, a single
+ hostname, or a fully qualified hostname.
+
- Return the IP-addresses for a host
+ Return the IP addresses for a host.
- Returns a list of all IP-addresses for Host .
- Host can be an IP-address, a single hostname or a fully
- qualified hostname.
+ Returns a list of all IP addresses for Host .
+ Host can be an IP address, a single hostname, or
+ a fully qualified hostname.
+
- Return a hostent record for the host with the given address
+ Return a hostent record for the host with the specified
+ address.
- Returns a hostent record given an address.
-
+ Returns a hostent record for the host with the specified
+ address.
+
- Return a hostent record for the host with the given name
+ Return a hostent record for the host with the specified name.
+
- Returns a hostent record given a hostname.
+ Returns a hostent record for the host with the specified
+ hostname.
+
- Return a hostent record for the host with the given name
+ Return a hostent record for the host with the specified name.
+
- Returns a hostent record given a hostname, restricted
- to the given address family.
+ Returns a hostent record for the host with the specified
+ name, restricted to the specified address family.
+
- Return the local hostname
+ Return the local hostname.
- Returns the local hostname. Will never fail.
+ Returns the local hostname. Never fails.
- Return a list of interfaces and their addresses
-
-
- Returns a list of 2-tuples containing interface names and the
- interface's addresses. Ifname is a Unicode string.
- Hwaddr is hardware dependent, e.g on Ethernet interfaces
- it is the 6-byte Ethernet address (MAC address (EUI-48 address)).
-
-
- The {addr,Addr } , {netmask,_} and {broadaddr,_}
- tuples are repeated in the result list iff the interface has multiple
- addresses. If you come across an interface that has
- multiple {flag,_} or {hwaddr,_} tuples you have
- a really strange interface or possibly a bug in this function.
- The {flag,_} tuple is mandatory, all other optional.
-
-
- Do not rely too much on the order of Flag atoms or
- Ifopt tuples. There are some rules, though:
-
- -
- Immediately after
{addr,_} follows {netmask,_}
-
- -
- Immediately thereafter follows
{broadaddr,_} if
- the broadcast flag is not set and the
- pointtopoint flag is set.
-
- -
- Any
{netmask,_} , {broadaddr,_} or
- {dstaddr,_} tuples that follow an {addr,_}
- tuple concerns that address.
-
-
-
- The {hwaddr,_} tuple is not returned on Solaris since the
- hardware address historically belongs to the link layer and only
- the superuser can read such addresses.
-
-
- On Windows, the data is fetched from quite different OS API
- functions, so the Netmask and Broadaddr
- values may be calculated, just as some Flag values.
- You have been warned. Report flagrant bugs.
-
-
+ Return a list of interfaces and their addresses.
+
+ Returns a list of 2-tuples containing interface names and the
+ interface addresses. Ifname is a Unicode string.
+ Hwaddr is hardware dependent, for example, on
+ Ethernet interfaces
+ it is the 6-byte Ethernet address (MAC address (EUI-48 address)).
+ The tuples {addr,Addr } , {netmask,_} , and
+ {broadaddr,_} are repeated in the result list if the interface
+ has multiple addresses. If you come across an interface with
+ multiple {flag,_} or {hwaddr,_} tuples, you have
+ a strange interface or possibly a bug in this function. The tuple
+ {flag,_} is mandatory, all others are optional.
+ Do not rely too much on the order of Flag atoms
+ or Ifopt tuples. There are however some rules:
+
+ Immediately after
+ {addr,_} follows {netmask,_} .
+ Immediately thereafter follows {broadaddr,_} if flag
+ broadcast is not set and flag
+ pointtopoint is set.
+ Any {netmask,_} , {broadaddr,_} , or
+ {dstaddr,_} tuples that follow an {addr,_}
+ tuple concerns that address.
+
+ The tuple {hwaddr,_} is not returned on Solaris, as the
+ hardware address historically belongs to the link layer and only
+ the superuser can read such addresses.
+
+ On Windows, the data is fetched from different OS API functions,
+ so the Netmask and Broadaddr
+ values can be calculated, just as some Flag
+ values. Report flagrant bugs.
+
+
- Get one or more options for a socket
+ Get one or more options for a socket.
- Gets one or more options for a socket.
- See setopts/2
- for a list of available options.
- The number of elements in the returned OptionValues
+
Gets one or more options for a socket. For a list of available
+ options, see
+ setopts/2 .
+ The number of elements in the returned
+ OptionValues
list does not necessarily correspond to the number of options
asked for. If the operating system fails to support an option,
- it is simply left out in the returned list. An error tuple is only
- returned when getting options for the socket is impossible
- (i.e. the socket is closed or the buffer size in a raw request
+ it is left out in the returned list. An error tuple is returned
+ only when getting options for the socket is impossible (that is,
+ the socket is closed or the buffer size in a raw request
is too large). This behavior is kept for backward
compatibility reasons.
- A raw option request RawOptReq = {raw, Protocol, OptionNum, ValueSpec} can be used to get information about
+
A raw option request
+ RawOptReq = {raw, Protocol, OptionNum, ValueSpec}
+ can be used to get information about
socket options not (explicitly) supported by the emulator. The
- use of raw socket options makes the code non portable, but
+ use of raw socket options makes the code non-portable, but
allows the Erlang programmer to take advantage of unusual features
present on the current platform.
- The RawOptReq consists of the tag raw followed
- by the protocol level, the option number and either a binary
+
RawOptReq consists of tag raw followed
+ by the protocol level, the option number, and either a binary
or the size, in bytes, of the
- buffer in which the option value is to be stored. A binary
- should be used when the underlying getsockopt requires
- input
- in the argument field, in which case the size of the binary
- should correspond to the required buffer
+ buffer in which the option value is to be stored. A binary is to be
+ used when the underlying getsockopt requires input
+ in the argument field. In this case, the binary size
+ is to correspond to the required buffer
size of the return value. The supplied values in a RawOptReq
- correspond to the second, third and fourth/fifth parameters to the
+ correspond to the second, third, and fourth/fifth parameters to the
getsockopt call in the C socket API. The value stored
- in the buffer is returned as a binary ValueBin
+ in the buffer is returned as a binary ValueBin ,
where all values are coded in the native endianess.
- Asking for and inspecting raw socket options require low
- level information about the current operating system and TCP
- stack.
- As an example, consider a Linux machine where the
- TCP_INFO option could be used to collect TCP statistics
- for a socket. Lets say we're interested in the
- tcpi_sacked field of the struct tcp_info
- filled in when asking for TCP_INFO . To
- be able to access this information, we need to know both the
- numeric value of the protocol level IPPROTO_TCP , the
- numeric value of the option TCP_INFO , the size of the
- struct tcp_info and the size and offset of
- the specific field. By inspecting the headers or writing a small C
- program, we found IPPROTO_TCP to be 6,
- TCP_INFO to be 11, the structure size to be 92 (bytes),
- the offset of tcpi_sacked to be 28 bytes and the actual
- value to be a 32 bit integer. We could use the following
- code to retrieve the value:
+ Asking for and inspecting raw socket options require low-level
+ information about the current operating system and TCP stack.
+ Example:
+ Consider a Linux machine where option
+ TCP_INFO can be used to collect TCP statistics
+ for a socket. Assume you are interested in field
+ tcpi_sacked of struct tcp_info
+ filled in when asking for TCP_INFO . To be able to access
+ this information, you need to know the following:
+
+ - The numeric value of protocol level
IPPROTO_TCP
+ - The numeric value of option
TCP_INFO
+ - The size of
struct tcp_info
+ - The size and offset of the specific field
+
+ By inspecting the headers or writing a small C program, it is found
+ that IPPROTO_TCP is 6, TCP_INFO is 11, the structure
+ size is 92 (bytes), the offset of tcpi_sacked is 28 bytes,
+ and the value is a 32-bit integer. The following code can be used
+ to retrieve the value:
- {ok,[{raw,_,_,Info}]} = inet:getopts(Sock,[{raw,6,11,92}]),
- <<_:28/binary,TcpiSacked:32/native,_/binary>> = Info,
- TcpiSacked.]]>
- Preferably, you would check the machine type, the OS
- and the kernel version prior to executing anything similar to the
- code above.
+get_tcpi_sacked(Sock) ->
+ {ok,[{raw,_,_,Info}]} = inet:getopts(Sock,[{raw,6,11,92}]),
+ <<_:28/binary,TcpiSacked:32/native,_/binary>> = Info,
+ TcpiSacked.]]>
+ Preferably, you would check the machine type, the operating system,
+ and the Kernel version before executing anything similar to
+ this code.
- Get one or more statistic options for a socket
+ Get one or more statistic options for a socket.
Gets one or more statistic options for a socket.
-
- getstat(Socket ) is equivalent to
- getstat(Socket , [recv_avg, recv_cnt, recv_dvi,
- recv_max, recv_oct, send_avg, send_cnt, send_dvi, send_max,
- send_oct]) .
- The following options are available:
+ getstat(Socket ) is equivalent to
+ getstat(Socket , [recv_avg, recv_cnt, recv_dvi,
+ recv_max, recv_oct, send_avg, send_cnt, send_dvi, send_max,
+ send_oct]) .
+ The following options are available:
- recv_avg
- -
-
Average size of packets in bytes received by the socket.
-
- recv_cnt
- -
+
recv_avg
+ -
+
Average size of packets, in bytes, received by the socket.
+
+ recv_cnt
+ -
Number of packets received by the socket.
-
- recv_dvi
- -
-
Average packet size deviation in bytes received by the socket.
-
- recv_max
- -
-
The size of the largest packet in bytes received by the socket.
-
- recv_oct
- -
+
+ recv_dvi
+ -
+
Average packet size deviation, in bytes, received by the socket.
+
+ recv_max
+ -
+
Size of the largest packet, in bytes, received by the socket.
+
+ recv_oct
+ -
Number of bytes received by the socket.
-
-
- send_avg
- -
-
Average size of packets in bytes sent from the socket.
-
- send_cnt
- -
+
+ send_avg
+ -
+
Average size of packets, in bytes, sent from the socket.
+
+ send_cnt
+ -
Number of packets sent from the socket.
-
- send_dvi
- -
-
Average packet size deviation in bytes sent from the socket.
-
- send_max
- -
-
The size of the largest packet in bytes sent from the socket.
-
- send_oct
- -
+
+ send_dvi
+ -
+
Average packet size deviation, in bytes, sent from the socket.
+
+ send_max
+ -
+
Size of the largest packet, in bytes, sent from the socket.
+
+ send_oct
+ -
Number of bytes sent from the socket.
-
+
+
- Convert IPv6 / IPV4 adress to ascii
+ Convert IPv6/IPV4 address to ASCII.
+
+ Parses an
+ ip_address()
+ and returns an IPv4 or IPv6 address string.
+
+
+
+
+
+ Parse an IPv4 or IPv6 address.
- Parses an ip_address() and returns an IPv4 or IPv6 address string.
+ Parses an IPv4 or IPv6 address string and returns an
+ ip4_address() or
+ ip6_address() .
+ Accepts a shortened IPv4 address string.
+
- Parse an IPv4 address
+ Parse an IPv4 address.
- Parses an IPv4 address string and returns an ip4_address() .
- Accepts a shortened IPv4 shortened address string.
+ Parses an IPv4 address string and returns an
+ ip4_address() .
+ Accepts a shortened IPv4 address string.
+
Parse an IPv4 address strict.
- Parses an IPv4 address string containing four fields, i.e not shortened, and returns an ip4_address() .
+ Parses an IPv4 address string containing four fields, that is,
+ not shortened, and returns an
+ ip4_address() .
+
+
- Parse an IPv6 address
+ Parse an IPv6 address.
- Parses an IPv6 address string and returns an ip6_address() .
- If an IPv4 address string is passed, an IPv4-mapped IPv6 address is returned.
+ Parses an IPv6 address string and returns an
+ ip6_address() .
+ If an IPv4 address string is specified, an IPv4-mapped IPv6 address
+ is returned.
+
Parse an IPv6 address strict.
- Parses an IPv6 address string and returns an ip6_address() .
- Does not accept IPv4 adresses.
-
-
-
-
- Parse an IPv4 or IPv6 address.
-
- Parses an IPv4 or IPv6 address string and returns an ip4_address() or ip6_address() . Accepts a shortened IPv4 address string.
+ Parses an IPv6 address string and returns an
+ ip6_address() .
+ Does not accept IPv4 addresses.
+
Parse an IPv4 or IPv6 address strict.
- Parses an IPv4 or IPv6 address string and returns an ip4_address() or ip6_address() . Does not accept a shortened IPv4 address string.
+ Parses an IPv4 or IPv6 address string and returns an
+ ip4_address() or
+ ip6_address() .
+ Does not accept a shortened IPv4 address string.
+
- Return the address and port for the other end of a connection
+ Return the address and port for the other end of a connection.
+
-
- Returns the address and port for the other end of a
- connection.
-
-
- Note that for SCTP sockets this function only returns
- one of the socket's peer addresses. The function
- peernames/1,2
- returns all.
-
+ Returns the address and port for the other end of a connection.
+ Notice that for SCTP sockets, this function returns only
+ one of the peer addresses of the socket. Function
+ peernames/1,2
+ returns all.
+
-
- Return all address/port numbers for the other end of a connection
-
+ Return all address/port numbers for the other end of a
+ connection.
-
- Equivalent to
+
Equivalent to
peernames(Socket , 0) .
- Note that this function's behaviour for an SCTP
+
+ Notice that the behavior of this function for an SCTP
one-to-many style socket is not defined by the
- SCTP Sockets API Extensions .
-
+ SCTP Sockets API Extensions .
+
-
- Return all address/port numbers for the other end of a connection
-
+ Return all address/port numbers for the other end of a
+ connection.
-
- Returns a list of all address/port number pairs for the other end
- of a socket's association Assoc .
-
-
- This function can return multiple addresses for multihomed
- sockets such as SCTP sockets. For other sockets it
- returns a one element list.
-
-
- Note that the Assoc parameter is by the
+
Returns a list of all address/port number pairs for the other end
+ of an association Assoc of a socket.
+ This function can return multiple addresses for multihomed
+ sockets, such as SCTP sockets. For other sockets it
+ returns a one-element list.
+ Notice that parameter Assoc is by the
SCTP Sockets API Extensions
defined to be ignored for
- one-to-one style sockets. What the special value 0
- means hence its behaviour for one-to-many style sockets
- is unfortunately not defined.
-
+ one-to-one style sockets. What the special value 0
+ means, hence its behavior for one-to-many style sockets,
+ is unfortunately undefined.
+
- Return the local port number for a socket
+ Return the local port number for a socket.
Returns the local port number for a socket.
-
-
- Return the local address and port number for a socket
-
- Returns the local address and port number for a socket.
-
- Note that for SCTP sockets this function only returns
- one of the socket addresses. The function
- socknames/1,2
- returns all.
-
-
-
-
-
- Return all local address/port numbers for a socket
-
-
- Equivalent to
- socknames(Socket , 0) .
-
-
-
-
-
- Return all local address/port numbers for a socket
-
-
- Returns a list of all local address/port number pairs for a socket
- for the given association Assoc .
-
-
- This function can return multiple addresses for multihomed
- sockets such as SCTP sockets. For other sockets it
- returns a one element list.
-
-
- Note that the Assoc parameter is by the
- SCTP Sockets API Extensions
- defined to be ignored for one-to-one style sockets.
- For one-to-many style sockets the special value 0
- is defined to mean that the returned addresses shall be
- without regard to any particular association.
- How different SCTP implementations interprets this varies somewhat.
-
-
-
+
- Set one or more options for a socket
+ Set one or more options for a socket.
- Sets one or more options for a socket. The following options
- are available:
+ Sets one or more options for a socket.
+ The following options are available:
{active, true | false | once | N}
-
If the value is true , which is the default,
- everything received from the socket will be sent as
- messages to the receiving process. If the value is
- false (passive mode), the process must explicitly
- receive incoming data by calling
+ everything received from the socket is sent as
+ messages to the receiving process.
+ If the value is false (passive mode), the process must
+ explicitly receive incoming data by calling
gen_tcp:recv/2,3 ,
- gen_udp:recv/2,3
+ gen_udp:recv/2,3 ,
or gen_sctp:recv/1,2
(depending on the type of socket).
If the value is once ({active, once} ),
- one data message from the socket will be sent
- to the process. To receive one more message,
- setopts/2 must be called again with the
- {active, once} option.
+ one data message from the socket is sent
+ to the process. To receive one more message,
+ setopts/2 must be called again with option
+ {active, once} .
If the value is an integer N in the range -32768 to 32767
(inclusive), the value is added to the socket's count of data
messages sent to the controlling process. A socket's default
- message count is 0. If a negative value is specified and its
- magnitude is equal to or greater than the socket's current
- message count, the socket's message count is set to 0. Once
- the socket's message count reaches 0, either due to sending
+ message count is 0 . If a negative value is specified, and
+ its magnitude is equal to or greater than the socket's current
+ message count, the socket's message count is set to 0 .
+ Once the socket's message count reaches 0 , either because
+ of sending
received data messages to the process or by being explicitly set,
the process is then notified by a special message, specific to
the type of socket, that the socket has entered passive
@@ -575,339 +559,298 @@ fe80::204:acff:fe17:bf38
messages setopts/2 must be called again to set the
socket back into an active mode.
When using {active, once} or {active, N} , the
- socket changes behaviour automatically when data is received.
- This can sometimes be confusing in combination with
- connection-oriented sockets (i.e. gen_tcp ) as a socket
- with {active, false} behaviour reports closing
+ socket changes behavior automatically when data is received.
+ This can be confusing in combination with connection-oriented
+ sockets (that is, gen_tcp ), as a socket
+ with {active, false} behavior reports closing
differently than a socket with {active, true}
- behaviour. To make programming easier, a socket where
- the peer closed and this was detected while in
- {active, false} mode, will still generate the
- message
+ behavior. To simplify programming, a socket where
+ the peer closed, and this is detected while in
+ {active, false} mode, still generates message
{tcp_closed,Socket} when set to {active, once} ,
- {active, true} or {active, N} mode. It is therefore
- safe to assume that the message
- {tcp_closed,Socket} , possibly followed by socket
- port termination (depending on the exit_on_close
- option) will eventually appear when a socket changes
+ {active, true} , or {active, N} mode.
+ It is therefore safe to assume that message
+ {tcp_closed,Socket} , possibly followed by socket port
+ termination (depending on option exit_on_close )
+ eventually appears when a socket changes
back and forth between {active, true} and
{active, false} mode. However,
- when peer closing is detected is all up to the
+ when peer closing is detected it is all up to the
underlying TCP/IP stack and protocol.
- Note that {active, true} mode provides no flow
- control; a fast sender could easily overflow the
- receiver with incoming messages. The same is true of
- {active, N} mode while the message count is greater
- than zero. Use active mode only if
+
Notice that {active, true} mode provides no flow
+ control; a fast sender can easily overflow the
+ receiver with incoming messages. The same is true for
+ {active, N} mode, while the message count is greater
+ than zero.
+ Use active mode only if
your high-level protocol provides its own flow control
- (for instance, acknowledging received messages) or the
+ (for example, acknowledging received messages) or the
amount of data exchanged is small. {active, false}
- mode, use of the {active, once} mode or {active, N}
+ mode, use of the {active, once} mode, or {active, N}
mode with values of N appropriate for the application
- provides flow control; the other side will not be able send
+ provides flow control. The other side cannot send
faster than the receiver can read.
-
- {broadcast, Boolean} (UDP sockets)
+ {broadcast, Boolean} (UDP sockets)
-
-
Enable/disable permission to send broadcasts.
-
+ Enables/disables permission to send broadcasts.
+
+
+ {buffer, Size}
+ -
+
The size of the user-level software buffer used by
+ the driver. Not to be confused with options sndbuf
+ and recbuf , which correspond to the
+ Kernel socket buffers. It is recommended
+ to have val(buffer) >= max(val(sndbuf),val(recbuf)) to
+ avoid performance issues because of unnecessary copying.
+ val(buffer) is automatically set to the above
+ maximum when values sndbuf or recbuf are set.
+ However, as the sizes set for sndbuf and recbuf
+ usually become larger, you are encouraged to use
+ getopts/2
+ to analyze the behavior of your operating system.
-
- {buffer, Size}
- -
-
The size of the user-level software buffer used by
- the driver. Not to be confused with sndbuf
- and recbuf options which correspond to
- the kernel socket buffers. It is recommended
- to have val(buffer) >= max(val(sndbuf),val(recbuf)) to
- avoid performance issues due to unnecessary copying.
- In fact, the val(buffer) is automatically set to
- the above maximum when sndbuf or recbuf values are set.
- However, since the actual sizes set for sndbuf and recbuf
- usually becomes larger, you are encouraged to use
- inet:getopts/2
- to analyze the behavior of your operating system.
-
-
{delay_send, Boolean}
-
Normally, when an Erlang process sends to a socket,
- the driver will try to immediately send the data. If that
- fails, the driver will use any means available to queue
+ the driver tries to send the data immediately. If that
+ fails, the driver uses any means available to queue
up the message to be sent whenever the operating system
says it can handle it. Setting {delay_send, true}
- will make all messages queue up. This makes
- the messages actually sent onto the network be larger but
- fewer. The option actually affects the scheduling of send
+ makes all messages queue up. The messages sent
+ to the network are then larger but fewer.
+ The option affects the scheduling of send
requests versus Erlang processes instead of changing any
- real property of the socket. Needless to say it is an
- implementation specific option. Default is false .
+ real property of the socket. The option is
+ implementation-specific. Defaults to false .
+
+ {deliver, port | term}
+ -
+
When {active, true} , data is delivered on the form
+ port : {S, {data, [H1,..Hsz | Data]}} or
+ term : {tcp, S, [H1..Hsz | Data]} .
-
- {deliver, port | term}
- -
When {active, true} delivers data on the forms
- port : {S, {data, [H1,..Hsz | Data]}} or
- term : {tcp, S, [H1..Hsz | Data]} .
-
-
-
{dontroute, Boolean}
-
-
Enable/disable routing bypass for outgoing messages.
+ Enables/disables routing bypass for outgoing messages.
-
{exit_on_close, Boolean}
-
-
By default this option is set to true .
+ This option is set to true by default.
The only reason to set it to false is if you want
- to continue sending data to the socket after a close has
- been detected, for instance if the peer has used
- gen_tcp:shutdown/2
- to shutdown the write side.
+ to continue sending data to the socket after a close is
+ detected, for example, if the peer uses
+ gen_tcp:shutdown/2
+ to shut down the write side.
-
{header, Size}
-
-
This option is only meaningful if the binary
- option was specified when the socket was created. If
- the header option is specified, the first
+
This option is only meaningful if option binary
+ was specified when the socket was created. If option
+ header is specified, the first
Size number bytes of data received from the socket
- will be elements of a list, and the rest of the data will
- be a binary given as the tail of the same list. If for
- example Size == 2 , the data received will match
+ are elements of a list, and the remaining data is
+ a binary specified as the tail of the same list. For example,
+ if Size == 2 , the data received matches
[Byte1,Byte2|Binary] .
-
{high_msgq_watermark, Size}
-
-
The socket message queue will be set into a busy
- state when the amount of data queued on the message
- queue reaches this limit. Note that this limit only
- concerns data that have not yet reached the ERTS internal
- socket implementation. Default value used is 8 kB.
- Senders of data to the socket will be suspended if
- either the socket message queue is busy, or the socket
- itself is busy.
- For more information see the low_msgq_watermark ,
- high_watermark , and low_watermark options.
- Note that distribution sockets will disable the use of
- high_msgq_watermark and low_msgq_watermark ,
- and will instead use the
- distribution
- buffer busy limit which is a similar feature.
+ The socket message queue is set to a busy
+ state when the amount of data on the message
+ queue reaches this limit. Notice that this limit only
+ concerns data that has not yet reached the ERTS internal
+ socket implementation. Defaults to 8 kB.
+ Senders of data to the socket are suspended if
+ either the socket message queue is busy or the socket
+ itself is busy.
+ For more information, see options low_msgq_watermark ,
+ high_watermark , and low_watermark .
+ Notice that distribution sockets disable the use of
+ high_msgq_watermark and low_msgq_watermark .
+ Instead use the
+ distribution buffer busy limit ,
+ which is a similar feature.
-
{high_watermark, Size} (TCP/IP sockets)
-
-
The socket will be set into a busy state when the amount
- of data queued internally by the ERTS socket implementation
- reaches this limit. Default value used is 8 kB.
- Senders of data to the socket will be suspended if
- either the socket message queue is busy, or the socket
- itself is busy.
- For more information see the low_watermark ,
- high_msgq_watermark , and low_msqg_watermark
- options.
+ The socket is set to a busy state when the amount
+ of data queued internally by the ERTS socket implementation
+ reaches this limit. Defaults to 8 kB.
+ Senders of data to the socket are suspended if
+ either the socket message queue is busy or the socket
+ itself is busy.
+ For more information, see options low_watermark ,
+ high_msgq_watermark , and low_msqg_watermark .
-
{ipv6_v6only, Boolean}
-
-
- Restricts the socket to only use IPv6, prohibiting any
+
Restricts the socket to use only IPv6, prohibiting any
IPv4 connections. This is only applicable for
- IPv6 sockets (option inet6 ).
-
-
- On most platforms this option has to be set on the socket
- before associating it to an address. Therefore it is only
- reasonable to give it when creating the socket and not
- to use it when calling the function
- (setopts/2 )
- containing this description.
-
-
- The behaviour of a socket with this socket option set to
- true is becoming the only portable one. The original
+ IPv6 sockets (option inet6 ).
+ On most platforms this option must be set on the socket
+ before associating it to an address. It is therefore only
+ reasonable to specify it when creating the socket and not
+ to use it when calling function
+ (setopts/2 )
+ containing this description.
+ The behavior of a socket with this option set to
+ true is the only portable one. The original
idea when IPv6 was new of using IPv6 for all traffic
is now not recommended by FreeBSD (you can use
{ipv6_v6only,false} to override the recommended
system default value),
- forbidden by OpenBSD (the supported GENERIC kernel)
- and impossible on Windows (that has separate
+ forbidden by OpenBSD (the supported GENERIC kernel),
+ and impossible on Windows (which has separate
IPv4 and IPv6 protocol stacks). Most Linux distros
still have a system default value of false .
- This policy shift among operating systems towards
- separating IPv6 from IPv4 traffic has evolved since
+ This policy shift among operating systems to
+ separate IPv6 from IPv4 traffic has evolved, as
it gradually proved hard and complicated to get
- a dual stack implementation correct and secure.
-
-
- On some platforms the only allowed value for this option
- is true , e.g. OpenBSD and Windows. Trying to set
- this option to false when creating the socket
- will in this case fail.
-
-
- Setting this option on platforms where it does not exist
- is ignored and getting this option with
- getopts/2
- returns no value i.e the returned list will not contain an
- {ipv6_v6only,_} tuple. On Windows the option acually
- does not exist, but it is emulated as being a
- read-only option with the value true .
-
-
- So it boils down to that setting this option to true
- when creating a socket will never fail except possibly
- (at the time of this writing) on a platform where you
+ a dual stack implementation correct and secure.
+ On some platforms, the only allowed value for this option
+ is true , for example, OpenBSD and Windows. Trying to set
+ this option to false , when creating the socket, fails
+ in this case.
+ Setting this option on platforms where it does not exist
+ is ignored. Getting this option with
+ getopts/2
+ returns no value, that is, the returned list does not contain an
+ {ipv6_v6only,_} tuple. On Windows, the option
+ does not exist, but it is emulated as a
+ read-only option with value true .
+ Therefore, setting this option to true
+ when creating a socket never fails, except possibly on a
+ platform where you
have customized the kernel to only allow false ,
- which might be doable (but weird) on e.g. OpenBSD.
-
-
- If you read back the option value using
- getopts/2
- and get no value the option does not exist in the host OS
- and all bets are off regarding the behaviour of both
- an IPv6 and an IPv4 socket listening on the same port
- as well as for an IPv6 socket getting IPv4 traffic.
-
+ which can be doable (but awkward) on, for example, OpenBSD.
+ If you read back the option value using
+ getopts/2
+ and get no value, the option does not exist in the host
+ operating system. The behavior of both an IPv6 and an IPv4
+ socket listening on the same port, and for an IPv6 socket
+ getting IPv4 traffic is then no longer predictable.
-
{keepalive, Boolean} (TCP/IP sockets)
-
Enables/disables periodic transmission on a connected
- socket, when no other data is being exchanged. If
+ socket when no other data is exchanged. If
the other end does not respond, the connection is
- considered broken and an error message will be sent to
- the controlling process. Default disabled.
-
+ considered broken and an error message is sent to
+ the controlling process. Defaults to disabled .
+
+
+ {linger, {true|false, Seconds}}
+ -
+
Determines the time-out, in seconds, for flushing unsent data
+ in the close/1 socket call. If the first component of
+ the value tuple is false , the second is ignored. This
+ means that close/1 returns immediately, not waiting
+ for data to be flushed. Otherwise, the second component is
+ the flushing time-out, in seconds.
-
- {linger, {true|false, Seconds}}
- -
-
Determines the timeout in seconds for flushing unsent data in the
- close/1 socket call. If the 1st component of the value
- tuple is false , the 2nd one is ignored, which means that
- close/1 returns immediately not waiting
- for data to be flushed. Otherwise, the 2nd component is
- the flushing time-out in seconds.
-
-
{low_msgq_watermark, Size}
-
If the socket message queue is in a busy state, the
- socket message queue will be set in a not busy state when
- the amount of data queued in the message queue falls
- below this limit. Note that this limit only concerns data
- that have not yet reached the ERTS internal socket
- implementation. Default value used is 4 kB.
- Senders that have been suspended due to either a
- busy message queue or a busy socket, will be resumed
- when neither the socket message queue, nor the socket
- are busy.
- For more information see the high_msgq_watermark ,
- high_watermark , and low_watermark options.
- Note that distribution sockets will disable the use of
- high_msgq_watermark and low_msgq_watermark ,
- and will instead use the
- distribution
- buffer busy limit which is a similar feature.
+ socket message queue is set in a not busy state when
+ the amount of data queued in the message queue falls
+ below this limit. Notice that this limit only concerns data
+ that has not yet reached the ERTS internal socket
+ implementation. Defaults to 4 kB.
+ Senders that are suspended because of either a
+ busy message queue or a busy socket are resumed
+ when the socket message queue and the socket
+ are not busy.
+ For more information, see options high_msgq_watermark ,
+ high_watermark , and low_watermark .
+ Notice that distribution sockets disable the use of
+ high_msgq_watermark and low_msgq_watermark .
+ Instead they use the
+ distribution
+ buffer busy limit , which is a similar feature.
-
{low_watermark, Size} (TCP/IP sockets)
-
-
If the socket is in a busy state, the socket will
- be set in a not busy state when the amount of data
- queued internally by the ERTS socket implementation
- falls below this limit. Default value used is 4 kB.
- Senders that have been suspended due to either a
- busy message queue or a busy socket, will be resumed
- when neither the socket message queue, nor the socket
- are busy.
- For more information see the high_watermark ,
- high_msgq_watermark , and low_msgq_watermark
- options.
+ If the socket is in a busy state, the socket is
+ set in a not busy state when the amount of data
+ queued internally by the ERTS socket implementation
+ falls below this limit. Defaults to 4 kB.
+ Senders that are suspended because of a
+ busy message queue or a busy socket are resumed
+ when the socket message queue and the socket are not busy.
+ For more information, see options high_watermark ,
+ high_msgq_watermark , and low_msgq_watermark .
-
- {mode, Mode :: binary | list}
+ {mode, Mode :: binary | list}
-
-
Received Packet is delivered as defined by Mode.
-
-
+ Received Packet is delivered as defined by Mode .
+
+
{netns, Namespace :: file:filename_all()}
-
-
Set a network namespace for the socket. The Namespace
- parameter is a filename defining the namespace for example
- "/var/run/netns/example" typically created by the command
- ip netns add example . This option must be used in a
- function call that creates a socket i.e
-
- gen_tcp:connect/3,4 ,
-
- gen_tcp:listen/2 ,
-
- gen_udp:open/1,2 or
-
- gen_sctp:open/0-2 .
-
- This option uses the Linux specific syscall
- setns() such as in Linux kernel 3.0 or later
- and therefore only exists when the runtime system
- has been compiled for such an operating system.
-
-
- The virtual machine also needs elevated privileges either
- running as superuser or (for Linux) having the capability
- CAP_SYS_ADMIN according to the documentation for setns(2).
- However, during testing also CAP_SYS_PTRACE
- and CAP_DAC_READ_SEARCH has proven to be necessary.
- Example:
-setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
-
- Note also that the filesystem containing the virtual machine
- executable (beam.smp in the example above) has to be local,
- mounted without the nosetuid flag,
- support extended attributes and that
- the kernel has to support file capabilities.
- All this runs out of the box on at least Ubuntu 12.04 LTS,
- except that SCTP sockets appears to not support
- network namespaces.
-
- The Namespace is a file name and is encoded
- and decoded as discussed in
- file
- except that the emulator flag +fnu is ignored and
- getopts/2
- for this option will return a binary for the filename
- if the stored filename can not be decoded,
- which should only happen if you set the option using a binary
- that can not be decoded with the emulator's filename encoding:
-
- file:native_name_encoding/0 .
-
-
-
- list
+ Sets a network namespace for the socket. Parameter
+ Namespace is a filename defining the namespace, for
+ example, "/var/run/netns/example" , typically created by
+ command ip netns add example . This option must be used in
+ a function call that creates a socket, that is,
+ gen_tcp:connect/3,4 ,
+ gen_tcp:listen/2 ,
+ gen_udp:open/1,2 , or
+ gen_sctp:open/0,1,2 .
+ This option uses the Linux-specific syscall
+ setns() , such as in Linux kernel 3.0 or later,
+ and therefore only exists when the runtime system
+ is compiled for such an operating system.
+ The virtual machine also needs elevated privileges, either
+ running as superuser or (for Linux) having capability
+ CAP_SYS_ADMIN according to the documentation for
+ setns(2) .
+ However, during testing also CAP_SYS_PTRACE
+ and CAP_DAC_READ_SEARCH have proven to be necessary.
+ Example:
+
+setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
+ Notice that the filesystem containing the virtual machine
+ executable (beam.smp in the example) must be local,
+ mounted without flag nosetuid ,
+ support extended attributes, and
+ the kernel must support file capabilities.
+ All this runs out of the box on at least Ubuntu 12.04 LTS,
+ except that SCTP sockets appear to not support
+ network namespaces.
+ Namespace is a filename and is encoded
+ and decoded as discussed in module
+ file , with the
+ following exceptions:
+
+ Emulator flag +fnu is ignored.
+ getopts/2
+ for this option returns a binary for the filename if the stored
+ filename cannot be decoded. This is only to occur if you set the
+ option using a binary that cannot be decoded with the emulator's
+ filename encoding:
+ file:native_name_encoding/0 .
+
+
+ list
-
-
Received Packet is delivered as a list.
-
-
- binary
+ Received Packet is delivered as a list.
+
+ binary
-
-
Received Packet is delivered as a binary.
-
-
+ Received Packet is delivered as a binary.
+
{nodelay, Boolean} (TCP/IP sockets)
-
-
If Boolean == true , the TCP_NODELAY option
- is turned on for the socket, which means that even small
- amounts of data will be sent immediately.
+ If Boolean == true , option TCP_NODELAY
+ is turned on for the socket, which means that also small
+ amounts of data are sent immediately.
{packet, PacketType} (TCP/IP sockets)
-
Defines the type of packets to use for a socket.
- The following values are valid:
+ Possible values:
raw | 0
-
@@ -917,104 +860,99 @@ setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
-
Packets consist of a header specifying the number of
bytes in the packet, followed by that number of bytes.
- The length of header can be one, two, or four bytes;
+ The header length can be one, two, or four bytes, and
containing an unsigned integer in big-endian byte order.
- Each send operation will generate the header, and the header
- will be stripped off on each receive operation.
- In current implementation the 4-byte header is limited to 2Gb.
+ Each send operation generates the header, and the header
+ is stripped off on each receive operation.
+ The 4-byte header is limited to 2Gb.
asn1 | cdr | sunrm | fcgi | tpkt | line
-
These packet types only have effect on receiving.
When sending a packet, it is the responsibility of
the application to supply a correct header. On
- receiving, however, there will be one message sent to
+ receiving, however, one message is sent to
the controlling process for each complete packet
received, and, similarly, each call to
gen_tcp:recv/2,3 returns one complete packet.
The header is not stripped off.
- The meanings of the packet types are as follows:
-
-asn1 - ASN.1 BER,
-
-sunrm - Sun's RPC encoding,
-
-cdr - CORBA (GIOP 1.1),
-
-fcgi - Fast CGI,
-
-tpkt - TPKT format [RFC1006],
-
-line - Line mode, a packet is a line
- terminated with newline, lines longer than
- the receive buffer are truncated.
-
+ The meanings of the packet types are as follows:
+
+ asn1 - ASN.1 BER
+ sunrm - Sun's RPC encoding
+ cdr - CORBA (GIOP 1.1)
+ fcgi - Fast CGI
+ tpkt - TPKT format [RFC1006]
+ line - Line mode, a packet is a line-terminated
+ with newline, lines longer than the receive buffer are
+ truncated
+
+
http | http_bin
-
The Hypertext Transfer Protocol. The packets
are returned with the format according to HttpPacket
- described in
- erlang:decode_packet/3 . A socket in passive
- mode will return {ok, HttpPacket} from gen_tcp:recv
- while an active socket will send messages like {http,
- Socket, HttpPacket} .
+ described in
+
+ erlang:decode_packet/3 in ERTS .
+ A socket in passive
+ mode returns {ok, HttpPacket} from gen_tcp:recv
+ while an active socket sends messages like
+ {http, Socket, HttpPacket} .
httph | httph_bin
-
-
These two types are often not needed as the socket will
- automatically switch from http /http_bin to
+
These two types are often not needed, as the socket
+ automatically switches from http /http_bin to
httph /httph_bin internally after the first line
- has been read. There might be occasions however when they are
+ is read. However, there can be occasions when they are
useful, such as parsing trailers from chunked encoding.
{packet_size, Integer} (TCP/IP sockets)
-
-
Sets the max allowed length of the packet body. If
+
Sets the maximum allowed length of the packet body. If
the packet header indicates that the length of the packet
- is longer than the max allowed length, the packet is
- considered invalid. The same happens if the packet header
- is too big for the socket receive buffer.
- For line oriented protocols (line ,http* ),
- option packet_size also guarantees that lines up to the
- indicated length are accepted and not considered invalid due
- to internal buffer limitations.
+ is longer than the maximum allowed length, the packet is
+ considered invalid. The same occurs if the packet header
+ is too large for the socket receive buffer.
+ For line-oriented protocols (line , http* ),
+ option packet_size also guarantees that lines up to the
+ indicated length are accepted and not considered invalid
+ because of internal buffer limitations.
{line_delimiter, Char} (TCP/IP sockets)
-
-
Sets the line delimiting character for line oriented protocols
- (line ). Default value is $\n .
+ Sets the line delimiting character for line-oriented protocols
+ (line ). Defaults to $\n .
+
+ {priority, Priority}
+ -
+
Sets the protocol-defined priority for all packets to be sent
+ on this socket.
+
+ {raw, Protocol, OptionNum, ValueBin}
+ -
+
See below.
-
- {priority, Priority}
- -
Set the protocol-defined priority for all packets to be sent
- on this socket.
-
-
- {raw, Protocol, OptionNum, ValueBin}
- -
See below.
-
-
{read_packets, Integer} (UDP sockets)
-
-
Sets the max number of UDP packets to read without
+
Sets the maximum number of UDP packets to read without
intervention from the socket when data is available.
When this many packets have been read and delivered
to the destination process, new packets are not read
until a new notification of available data has arrived.
- The default is 5, and if this parameter is set too
- high the system can become unresponsive due to
+ Defaults to 5 . If this parameter is set too
+ high, the system can become unresponsive because of
UDP packet flooding.
{recbuf, Size}
-
The minimum size of the receive buffer to use for
the socket. You are encouraged to use
- inet:getopts/2 ,
- to retrieve the actual size set by your operating system.
-
-
+ getopts/2
+ to retrieve the size set by your operating system.
{reuseaddr, Boolean}
-
@@ -1023,118 +961,160 @@ setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
{send_timeout, Integer}
-
-
Only allowed for connection oriented sockets.
+ Only allowed for connection-oriented sockets.
Specifies a longest time to wait for a send operation to
be accepted by the underlying TCP stack. When the limit is
- exceeded, the send operation will return
- {error,timeout} . How much of a packet that actually
- got sent is unknown, why the socket should be closed
- whenever a timeout has occurred (see send_timeout_close ).
- Default is infinity .
+ exceeded, the send operation returns
+ {error,timeout} . How much of a packet that
+ got sent is unknown; the socket is therefore to be closed
+ whenever a time-out has occurred (see send_timeout_close
+ below). Defaults to infinity .
{send_timeout_close, Boolean}
-
-
Only allowed for connection oriented sockets.
+ Only allowed for connection-oriented sockets.
Used together with send_timeout to specify whether
- the socket will be automatically closed when the send operation
+ the socket is to be automatically closed when the send operation
returns {error,timeout} . The recommended setting is
- true which will automatically close the socket.
- Default is false due to backward compatibility.
-
+ true , which automatically closes the socket.
+ Defaults to false because of backward compatibility.
+
-
{show_econnreset, Boolean} (TCP/IP sockets)
-
-
When this option is set to false , as it is by
- default, an RST that is received from the TCP peer is treated
- as a normal close (as though a FIN was sent). A caller
- to gen_tcp:recv/2
- will get {error, closed} . In active
- mode the controlling process will receive a
+
When this option is set to false , which is
+ default, an RST received from the TCP peer is treated
+ as a normal close (as though an FIN was sent). A caller to
+ gen_tcp:recv/2
+ gets {error, closed} . In active
+ mode, the controlling process receives a
{tcp_close, Socket} message, indicating that the
peer has closed the connection.
- Setting this option to true will allow you to
+
Setting this option to true allows you to
distinguish between a connection that was closed normally,
- and one which was aborted (intentionally or unintentionally)
+ and one that was aborted (intentionally or unintentionally)
by the TCP peer. A call to
- gen_tcp:recv/2
- will return {error, econnreset} . In
- active mode, the controlling process will receive a
+ gen_tcp:recv/2
+ returns {error, econnreset} . In
+ active mode, the controlling process receives a
{tcp_error, Socket, econnreset} message
before the usual {tcp_closed, Socket} , as is
the case for any other socket error. Calls to
- gen_tcp:send/2
- will also return {error, econnreset} when it
+ gen_tcp:send/2
+ also returns {error, econnreset} when it
is detected that a TCP peer has sent an RST.
A connected socket returned from
- gen_tcp:accept/1
- will inherit the show_econnreset setting from the
+ gen_tcp:accept/1
+ inherits the show_econnreset setting from the
listening socket.
-
+
-
{sndbuf, Size}
-
The minimum size of the send buffer to use for the socket.
- You are encouraged to use
- inet:getopts/2 ,
- to retrieve the actual size set by your operating system.
-
+ You are encouraged to use
+ getopts/2 ,
+ to retrieve the size set by your operating system.
{priority, Integer}
-
-
Sets the SO_PRIORITY socket level option on platforms where
- this is implemented. The behaviour and allowed range varies on
- different systems. The option is ignored on platforms where the
- option is not implemented. Use with caution.
+ Sets the SO_PRIORITY socket level option on platforms
+ where this is implemented. The behavior and allowed range varies
+ between different systems.
+ The option is ignored on platforms where it
+ is not implemented. Use with caution.
{tos, Integer}
-
-
Sets IP_TOS IP level options on platforms where this is
- implemented. The behaviour and allowed range varies on different
- systems. The option is ignored on platforms where the option is
- not implemented. Use with caution.
+ Sets IP_TOS IP level options on platforms where this is
+ implemented. The behavior and allowed range varies between
+ different systems.
+ The option is ignored on platforms where it is not
+ implemented. Use with caution.
-
- In addition to the options mentioned above, raw
+
In addition to these options, raw
option specifications can be used. The raw options are
- specified as a tuple of arity four, beginning with the tag
- raw , followed by the protocol level, the option number
- and the actual option value specified as a binary. This
- corresponds to the second, third and fourth argument to the
+ specified as a tuple of arity four, beginning with tag
+ raw , followed by the protocol level, the option number,
+ and the option value specified as a binary. This
+ corresponds to the second, third, and fourth arguments to the
setsockopt call in the C socket API. The option value
- needs to be coded in the native endianess of the platform and,
- if a structure is required, needs to follow the struct
+ must be coded in the native endianess of the platform and,
+ if a structure is required, must follow the structure
alignment conventions on the specific platform.
- Using raw socket options require detailed knowledge about
+
Using raw socket options requires detailed knowledge about
the current operating system and TCP stack.
- As an example of the usage of raw options, consider a Linux
- system where you want to set the TCP_LINGER2 option on
- the IPPROTO_TCP protocol level in the stack. You know
+
Example:
+ This example concerns the use of raw options. Consider a Linux
+ system where you want to set option TCP_LINGER2 on
+ protocol level IPPROTO_TCP in the stack. You know
that on this particular system it defaults to 60 (seconds),
- but you would like to lower it to 30 for a particular
- socket. The TCP_LINGER2 option is not explicitly
- supported by inet, but you know that the protocol level
- translates to the number 6, the option number to the number 8
- and the value is to be given as a 32 bit integer. You can use
- this line of code to set the option for the socket named
+ but you want to lower it to 30 for a particular
+ socket. Option TCP_LINGER2 is not explicitly
+ supported by inet , but you know that the protocol level
+ translates to number 6, the option number to number 8,
+ and the value is to be specified as a 32-bit integer. You can use
+ this code line to set the option for the socket named
Sock :
>}]),]]>
+inet:setopts(Sock,[{raw,6,8,<<30:32/native>>}]),]]>
As many options are silently discarded by the stack if they
- are given out of range, it could be a good idea to check that
- a raw option really got accepted. This code places the value
- in the variable TcpLinger2:
+ are specified out of range; it can be a good idea to check that
+ a raw option is accepted. The following code places the value
+ in variable TcpLinger2:
>}]}=inet:getopts(Sock,[{raw,6,8,4}]),]]>
- Code such as the examples above is inherently non portable,
- even different versions of the same OS on the same platform
- may respond differently to this kind of option
+{ok,[{raw,6,8,<>}]}=inet:getopts(Sock,[{raw,6,8,4}]),]]>
+ Code such as these examples is inherently non-portable,
+ even different versions of the same OS on the same platform
+ can respond differently to this kind of option
manipulation. Use with care.
- Note that the default options for TCP/IP sockets can be
- changed with the Kernel configuration parameters mentioned in
- the beginning of this document.
+ Notice that the default options for TCP/IP sockets can be
+ changed with the Kernel configuration parameters mentioned in
+ the beginning of this manual page.
+
+
+
+
+
+ Return the local address and port number for a socket.
+
+
+ Returns the local address and port number for a socket.
+ Notice that for SCTP sockets this function returns only
+ one of the socket addresses. Function
+ socknames/1,2
+ returns all.
+
+
+
+
+
+ Return all local address/port numbers for a socket.
+
+ Equivalent to
+ socknames(Socket , 0) .
+
+
+
+
+
+
+ Return all local address/port numbers for a socket.
+
+ Returns a list of all local address/port number pairs for a socket
+ for the specified association Assoc .
+ This function can return multiple addresses for multihomed
+ sockets, such as SCTP sockets. For other sockets it
+ returns a one-element list.
+ Notice that parameter Assoc is by the
+ SCTP Sockets API Extensions
+ defined to be ignored for one-to-one style sockets.
+ For one-to-many style sockets, the special value 0
+ is defined to mean that the returned addresses must be
+ without any particular association.
+ How different SCTP implementations interprets this varies somewhat.
+
@@ -1143,148 +1123,147 @@ setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
POSIX Error Codes
- e2big - argument list too long
- eacces - permission denied
- eaddrinuse - address already in use
- eaddrnotavail - cannot assign requested address
- eadv - advertise error
- eafnosupport - address family not supported by
- protocol family
- eagain - resource temporarily unavailable
+ e2big - Too long argument list
+ eacces - Permission denied
+ eaddrinuse - Address already in use
+ eaddrnotavail - Cannot assign requested address
+ eadv - Advertise error
+ eafnosupport - Address family not supported by
+ protocol family
+ eagain - Resource temporarily unavailable
ealign - EALIGN
- ealready - operation already in progress
- ebade - bad exchange descriptor
- ebadf - bad file number
- ebadfd - file descriptor in bad state
- ebadmsg - not a data message
- ebadr - bad request descriptor
- ebadrpc - RPC structure is bad
- ebadrqc - bad request code
- ebadslt - invalid slot
- ebfont - bad font file format
- ebusy - file busy
- echild - no children
- echrng - channel number out of range
- ecomm - communication error on send
- econnaborted - software caused connection abort
- econnrefused - connection refused
- econnreset - connection reset by peer
- edeadlk - resource deadlock avoided
- edeadlock - resource deadlock avoided
- edestaddrreq - destination address required
- edirty - mounting a dirty fs w/o force
- edom - math argument out of range
- edotdot - cross mount point
- edquot - disk quota exceeded
- eduppkg - duplicate package name
- eexist - file already exists
- efault - bad address in system call argument
- efbig - file too large
- ehostdown - host is down
- ehostunreach - host is unreachable
- eidrm - identifier removed
- einit - initialization error
- einprogress - operation now in progress
- eintr - interrupted system call
- einval - invalid argument
+ ealready - Operation already in progress
+ ebade - Bad exchange descriptor
+ ebadf - Bad file number
+ ebadfd - File descriptor in bad state
+ ebadmsg - Not a data message
+ ebadr - Bad request descriptor
+ ebadrpc - Bad RPC structure
+ ebadrqc - Bad request code
+ ebadslt - Invalid slot
+ ebfont - Bad font file format
+ ebusy - File busy
+ echild - No children
+ echrng - Channel number out of range
+ ecomm - Communication error on send
+ econnaborted - Software caused connection abort
+ econnrefused - Connection refused
+ econnreset - Connection reset by peer
+ edeadlk - Resource deadlock avoided
+ edeadlock - Resource deadlock avoided
+ edestaddrreq - Destination address required
+ edirty - Mounting a dirty fs without force
+ edom - Math argument out of range
+ edotdot - Cross mount point
+ edquot - Disk quota exceeded
+ eduppkg - Duplicate package name
+ eexist - File already exists
+ efault - Bad address in system call argument
+ efbig - File too large
+ ehostdown - Host is down
+ ehostunreach - Host is unreachable
+ eidrm - Identifier removed
+ einit - Initialization error
+ einprogress - Operation now in progress
+ eintr - Interrupted system call
+ einval - Invalid argument
eio - I/O error
- eisconn - socket is already connected
- eisdir - illegal operation on a directory
- eisnam - is a named file
- el2hlt - level 2 halted
- el2nsync - level 2 not synchronized
- el3hlt - level 3 halted
- el3rst - level 3 reset
+ eisconn - Socket is already connected
+ eisdir - Illegal operation on a directory
+ eisnam - Is a named file
+ el2hlt - Level 2 halted
+ el2nsync - Level 2 not synchronized
+ el3hlt - Level 3 halted
+ el3rst - Level 3 reset
elbin - ELBIN
- elibacc - cannot access a needed shared library
- elibbad - accessing a corrupted shared library
- elibexec - cannot exec a shared library directly
- elibmax - attempting to link in more shared
- libraries than system limit
- elibscn - .lib section in a.out corrupted
- elnrng - link number out of range
- eloop - too many levels of symbolic links
- emfile - too many open files
- emlink - too many links
- emsgsize - message too long
- emultihop - multihop attempted
- enametoolong - file name too long
- enavail - not available
+ elibacc - Cannot access a needed shared library
+ elibbad - Accessing a corrupted shared library
+ elibexec - Cannot exec a shared library directly
+ elibmax - Attempting to link in more shared
+ libraries than system limit
+ elibscn - .lib section in a.out
+ corrupted
+ elnrng - Link number out of range
+ eloop - Too many levels of symbolic links
+ emfile - Too many open files
+ emlink - Too many links
+ emsgsize - Message too long
+ emultihop - Multihop attempted
+ enametoolong - Filename too long
+ enavail - Unavailable
enet - ENET
- enetdown - network is down
- enetreset - network dropped connection on reset
- enetunreach - network is unreachable
- enfile - file table overflow
- enoano - anode table overflow
- enobufs - no buffer space available
- enocsi - no CSI structure available
- enodata - no data available
- enodev - no such device
- enoent - no such file or directory
- enoexec - exec format error
- enolck - no locks available
- enolink - link has be severed
- enomem - not enough memory
- enomsg - no message of desired type
- enonet - machine is not on the network
- enopkg - package not installed
- enoprotoopt - bad protocol option
- enospc - no space left on device
- enosr - out of stream resources or not a stream
- device
- enosym - unresolved symbol name
- enosys - function not implemented
- enotblk - block device required
- enotconn - socket is not connected
- enotdir - not a directory
- enotempty - directory not empty
- enotnam - not a named file
- enotsock - socket operation on non-socket
- enotsup - operation not supported
- enotty - inappropriate device for ioctl
- enotuniq - name not unique on network
- enxio - no such device or address
- eopnotsupp - operation not supported on socket
- eperm - not owner
- epfnosupport - protocol family not supported
- epipe - broken pipe
- eproclim - too many processes
- eprocunavail - bad procedure for program
- eprogmismatch - program version wrong
- eprogunavail - RPC program not available
- eproto - protocol error
- eprotonosupport - protocol not supported
- eprototype - protocol wrong type for socket
- erange - math result unrepresentable
+ enetdown - Network is down
+ enetreset - Network dropped connection on reset
+ enetunreach - Network is unreachable
+ enfile - File table overflow
+ enoano - Anode table overflow
+ enobufs - No buffer space available
+ enocsi - No CSI structure available
+ enodata - No data available
+ enodev - No such device
+ enoent - No such file or directory
+ enoexec - Exec format error
+ enolck - No locks available
+ enolink - Link has been severed
+ enomem - Not enough memory
+ enomsg - No message of desired type
+ enonet - Machine is not on the network
+ enopkg - Package not installed
+ enoprotoopt - Bad protocol option
+ enospc - No space left on device
+ enosr - Out of stream resources or not a stream device
+ enosym - Unresolved symbol name
+ enosys - Function not implemented
+ enotblk - Block device required
+ enotconn - Socket is not connected
+ enotdir - Not a directory
+ enotempty - Directory not empty
+ enotnam - Not a named file
+ enotsock - Socket operation on non-socket
+ enotsup - Operation not supported
+ enotty - Inappropriate device for ioctl
+ enotuniq - Name not unique on network
+ enxio - No such device or address
+ eopnotsupp - Operation not supported on socket
+ eperm - Not owner
+ epfnosupport - Protocol family not supported
+ epipe - Broken pipe
+ eproclim - Too many processes
+ eprocunavail - Bad procedure for program
+ eprogmismatch - Wrong program version
+ eprogunavail - RPC program unavailable
+ eproto - Protocol error
+ eprotonosupport - Protocol not supported
+ eprototype - Wrong protocol type for socket
+ erange - Math result unrepresentable
erefused - EREFUSED
- eremchg - remote address changed
- eremdev - remote device
- eremote - pathname hit remote file system
- eremoteio - remote i/o error
+ eremchg - Remote address changed
+ eremdev - Remote device
+ eremote - Pathname hit remote filesystem
+ eremoteio - Remote I/O error
eremoterelease - EREMOTERELEASE
- erofs - read-only file system
- erpcmismatch - RPC version is wrong
- erremote - object is remote
- eshutdown - cannot send after socket shutdown
- esocktnosupport - socket type not supported
- espipe - invalid seek
- esrch - no such process
- esrmnt - srmount error
- estale - stale remote file handle
+ erofs - Read-only filesystem
+ erpcmismatch - Wrong RPC version
+ erremote - Object is remote
+ eshutdown - Cannot send after socket shutdown
+ esocktnosupport - Socket type not supported
+ espipe - Invalid seek
+ esrch - No such process
+ esrmnt - Srmount error
+ estale - Stale remote file handle
esuccess - Error 0
- etime - timer expired
- etimedout - connection timed out
- etoomanyrefs - too many references
- etxtbsy - text file or pseudo-device busy
- euclean - structure needs cleaning
- eunatch - protocol driver not attached
- eusers - too many users
- eversion - version mismatch
- ewouldblock - operation would block
- exdev - cross-domain link
- exfull - message tables full
- nxdomain - the hostname or domain name could not be
- found
+ etime - Timer expired
+ etimedout - Connection timed out
+ etoomanyrefs - Too many references
+ etxtbsy - Text file or pseudo-device busy
+ euclean - Structure needs cleaning
+ eunatch - Protocol driver not attached
+ eusers - Too many users
+ eversion - Version mismatch
+ ewouldblock - Operation would block
+ exdev - Cross-domain link
+ exfull - Message tables full
+ nxdomain - Hostname or domain name cannot be found
Performs DNS name resolving towards recursive name servers
-See also
-
This module performs DNS name resolving to recursive name servers.
+See also
+
This DNS client can resolve DNS records even if it is not used for normal name resolving in the node.
-This is not a full-fledged resolver. It is just a - DNS client that relies on asking trusted recursive nameservers.
+This is not a full-fledged resolver, only a + DNS client that relies on asking trusted recursive name servers.
UDP queries are used unless resolver option
When EDNS is enabled (resolver option
+
For UDP queries, the resolver options
For UDP queries, resolver options
For queries that not use the
For queries not using the
This is the start of a hiearchy of opaque data structures - that can be examined with access functions in inet_dns that - return lists of {Field,Value} tuples. The arity 2 functions - just return the value for a given field.
-+ that can be examined with access functions ininet_dns , which + return lists of{Field,Value} tuples. The arity 2 functions + only return the value for a specified field. +dns_msg() = DnsMsg inet_dns:msg(DnsMsg) -> [ {header, dns_header()} @@ -163,63 +163,55 @@ dns_rr() = DnsRr | {z, integer()} | {data, dns_data()} ] inet_dns:rr(DnsRr, Field) -> Value- -There is an info function for the types above:
- -+There is an information function for the types above:
+inet_dns:record_type(dns_msg()) -> msg; inet_dns:record_type(dns_header()) -> header; inet_dns:record_type(dns_query()) -> dns_query; inet_dns:record_type(dns_rr()) -> rr; inet_dns:record_type(_) -> undefined.- -So; inet_dns:(inet_dns:record_type(X))(X) will convert -any of these data structures into a {Field,Value} list.
+So,
inet_dns:(inet_dns:record_type(X))(X) converts + any of these data structures into a{Field,Value} list.
Resolve a DNS record of the given type for the given host,
- of class
- This function uses the resolver option
Resolves a DNS record of the specified type for the specified host,
+ of class
This function uses resolver option
Backend functions used by
-
Backend functions used by
-
- This function uses the resolver option
- If the resolver option
This function uses resolver option
If resolver option
Resolve the DNS data for the record of the given type and class
- for the given name. On success filters out the answer records
- with the correct
Resolves the DNS data for the record of the specified type and class
+ for the specified name. On success, filters out the answer records
+ with the correct
- Calls
Calls
+
Resolve a DNS record of the given type and class for the given name.
- The returned
- If
-
- The
Resolves a DNS record of the specified type and class for the
+ specified name. The returned
If
Option
- If
If
- The
Option
Access functions example: how
-
- example_lookup(Name, Class, Type) ->
- case inet_res:resolve(Name, Class, Type) of
- {ok,Msg} ->
- [inet_dns:rr(RR, data)
- || RR <- inet_dns:msg(Msg, anlist),
- inet_dns:rr(RR, type) =:= Type,
- inet_dns:rr(RR, class) =:= Class];
- {error,_} ->
- []
- end.
+ This access functions example shows how
+
+example_lookup(Name, Class, Type) ->
+ case inet_res:resolve(Name, Class, Type) of
+ {ok,Msg} ->
+ [inet_dns:rr(RR, data)
+ || RR <- inet_dns:msg(Msg, anlist),
+ inet_dns:rr(RR, type) =:= Type,
+ inet_dns:rr(RR, class) =:= Class];
+ {error,_} ->
+ []
+ end.
These have been deprecated due to the annoying double - meaning of the nameservers/timeout argument, and - because they had no decent place for a resolver options list.
+These are deprecated because the annoying double + meaning of the name servers/time-out argument, and + because they have no decent place for a resolver options list.
Resolve a DNS record of the given type and class for the given name. -
+Resolves a DNS record of the specified type and class for the + specified name.
Resolve a DNS record of the given type and class for the given name. -
+Resolves a DNS record of the specified type and class for the + specified name.
-
- The module init is moved to the runtime system
- application. Please see
This module is moved to the
+
The Kernel application is the first application started. It is +
The
The
Two standard error logger event handlers are defined in
- the Kernel application. These are described in
-
The following configuration parameters are defined for the Kernel
- application. See
The following configuration parameters are defined for the
When pressing the Help button in a tool such as Debugger or
- TV, the help text (an HTML file
When pressing the Help button in a tool such as Debugger,
+ the help text (an HTML file
If set to a string
If set to a module-function-args tuple
If set to a module-function-args tuple,
Specifies which applications are distributed and on which - nodes they may execute. In this parameter:
+Specifies which applications that are distributed and on which + nodes they are allowed to execute. In this parameter:
The parameter is described in
-
Specifies when nodes will be automatically connected. If +
Specifies when nodes are automatically connected. If
this parameter is not specified, a node is always
- automatically connected, e.g when a message is to be sent to
+ automatically connected, for example, when a message is to be sent to
that node.
Connections are never automatically established, they
must be explicitly connected. See
-
Connections are established automatically, but only
once per node. If a node goes down, it must thereafter be
explicitly connected. See
-
Permissions are described in
-
Installs the standard event handler, which prints error
+ reports to
Installs the standard event handler, which prints error
+ reports to file
No standard event handler is installed, but the initial, primitive event handler is kept, printing - raw event messages to tty.
+ raw event messages toThis parameter can be used to limit the size of the +
Can be used to limit the size of the formatted output from the error logger event handlers.
-This configuration parameter was introduced in OTP 18.1.
- It is currently experimental. Based on user feedback it
- may be changed or improved in future releases, for example
+ This configuration parameter was introduced in OTP 18.1
+ and is experimental. Based on user feedback, it
+ can be changed or improved in future releases, for example,
to gain better control over how to limit the size of the
- formatted output. We have no plans to entirely remove this
- new feature, unless it turns out to be completely
- useless. In OTP 19, the default may be changed to limit the
- formatted output.
The way
A reasonable starting value for
Defines global groups, see
-
Specifies default options for
Specifies default options for
If the host of an Erlang node has several network interfaces,
- this parameter specifies which one to listen on. See
-
If the host of an Erlang node has many network interfaces,
+ this parameter specifies which one to listen on. For the type definition
+ of
See below.
-Define the
Defines the
Define a list of extra socket options to be used when opening the +
Defines a list of extra socket options to be used when opening the
listening socket for a distributed Erlang node.
- See
Define a list of extra socket options to be used when connecting to +
Defines a list of extra socket options to be used when connecting to
other distributed Erlang nodes.
- See
If this configuration parameter is set, no +
If set, no
The name (string) of an Inet user configuration file. See - ERTS User's Guide, Inet configuration.
+The name (string) of an Inet user configuration file. For details,
+ see section
+
Note that this value does not limit the total connection
+ Erlang node. The maximum allowed value is
Notice that this value does not limit the total connection setup time, but rather each individual network operation during the connection setup and handshake.
Specifies the
The time
MinT = TickTime - TickTime / 4
MaxT = TickTime + TickTime / 4
- Note: All communicating nodes should have the same +
Notice that all communicating nodes are to have the same
Note: Normally, a terminating node is detected - immediately.
+Normally, a terminating node is detected immediately.
Specifies the time
Specifies the time
Specifies which other nodes must be alive in order +
Specifies which other nodes that must be alive for this node to start properly. If some node in the list - does not start within the specified time, this node will not + does not start within the specified time, this node does not start either. If this parameter is undefined, it defaults to - [].
+Specifies which other nodes can be alive in order +
Specifies which other nodes that can be alive for this node to start properly. If some node in this list does not start within the specified time, this node starts anyway. If this parameter is undefined, it defaults to @@ -314,66 +303,65 @@ MaxT = TickTime + TickTime / 4
Specifies the amount of time (in milliseconds) this node - will wait for the mandatory and optional nodes to start. If +
Specifies the time (in milliseconds) that this node
+ waits for the mandatory and optional nodes to start. If
this parameter is undefined, no node synchronization is
- performed. This option also makes sure that
Starts the
The default value is
Defaults to
Starts the
The default value is
Defaults to
If the
If configuration parameter
+
where
Examples of
-
The default value is
Examples of
Defaults to
Starts the
The default value is
Defaults to
Starts the
The default value is
Defaults to
Starts the
The default value is
Defaults to
Sets a function that
This module contains various network utility functions.
Returns the official name of
Reads the
Reads file
Returns the name of the local host. If Erlang was started
- with the
Similar to
Returns
Similar to
Example:
(arne@dunn)1> net_adm:names().
{ok,[{"arne",40262}]}
Tries to set up a connection to
Sets up a connection to
This function calls
Calls
This function can be useful when a node is started, and - the names of the other nodes in the network are not initially - known.
-Failure:
Returns
As
Same as
The
File
The format of the
The format of file
Example:
'super.eua.ericsson.se'.
'renat.eua.ericsson.se'.
diff --git a/lib/kernel/doc/src/net_kernel.xml b/lib/kernel/doc/src/net_kernel.xml
index 311e0d8ea4..2d52adc2eb 100644
--- a/lib/kernel/doc/src/net_kernel.xml
+++ b/lib/kernel/doc/src/net_kernel.xml
@@ -25,41 +25,47 @@
net_kernel
Claes Wikstrom
1
- 96-09-10
+ 1996-09-10
A
net_kernel
- Erlang Networking Kernel
+ Erlang networking kernel.
The net kernel is a system process, registered as
- net_kernel , which must be running for distributed Erlang
+ net_kernel , which must be operational for distributed Erlang
to work. The purpose of this process is to implement parts of
the BIFs spawn/4 and spawn_link/4 , and to provide
monitoring of the network.
- An Erlang node is started using the command line flag
+
An Erlang node is started using command-line flag
-name or -sname :
-$ erl -sname foobar
+
+$ erl -sname foobar
It is also possible to call net_kernel:start([foobar])
directly from the normal Erlang shell prompt:
-1> net_kernel:start([foobar, shortnames]).
+
+1> net_kernel:start([foobar, shortnames]).
{ok,<0.64.0>}
(foobar@gringotts)2>
- If the node is started with the command line flag -sname ,
- the node name will be foobar@Host , where Host is
+
If the node is started with command-line flag -sname ,
+ the node name is foobar@Host , where Host is
the short name of the host (not the fully qualified domain name).
- If started with the -name flag, Host is the fully
- qualified domain name. See erl(1) .
+ If started with flag -name , the node name is foobar@Host ,
+ where Host is the fully qualified domain name.
+ For more information, see
+ erl .
Normally, connections are established automatically when
another node is referenced. This functionality can be disabled
- by setting the Kernel configuration parameter
+ by setting Kernel configuration parameter
dist_auto_connect to false , see
- kernel(6) . In this case,
+ kernel(6) . In this case,
connections must be established explicitly by calling
- net_kernel:connect_node/1 .
- Which nodes are allowed to communicate with each other is handled
- by the magic cookie system, see
- Distributed Erlang in the Erlang Reference Manual.
+ connect_node/1 .
+ Which nodes that are allowed to communicate with each other is handled
+ by the magic cookie system, see section
+ Distributed Erlang
+ in the Erlang Reference Manual.
+
@@ -77,237 +83,240 @@
an atom.
+
- Establish a connection to a node
+ Establish a connection to a node.
- Establishes a connection to Node . Returns true
- if successful, false if not, and ignored if
- the local node is not alive.
+ Establishes a connection to Node . Returns
+ true if successful, false if not, and ignored
+ if the local node is not alive.
+
+
+
+
+
+ Get net_ticktime .
+
+ Gets net_ticktime (see
+ kernel(6) ).
+ Defined return values (Res ):
+
+ NetTicktime
+ net_ticktime is NetTicktime
+ seconds.
+ {ongoing_change_to, NetTicktime }
+ net_kernel is currently changing
+ net_ticktime to NetTicktime
+ seconds.
+ ignored
+ The local node is not alive.
+
+
- Subscribe to node status change messages
+ Subscribe to node status change messages.
The calling process subscribes or unsubscribes to node
status change messages. A nodeup message is delivered
- to all subscribing process when a new node is connected, and
+ to all subscribing processes when a new node is connected, and
a nodedown message is delivered when a node is
disconnected.
- If Flag is true , a new subscription is started.
- If Flag is false , all previous subscriptions --
- started with the same Options -- are stopped. Two
+
If Flag is true , a new subscription is
+ started. If Flag is false , all previous
+ subscriptions started with the same Options
+ are stopped. Two
option lists are considered the same if they contain the same
set of options.
- As of kernel version 2.11.4, and erts version
+
As from Kernel version 2.11.4, and ERTS version
5.5.4, the following is guaranteed:
- nodeup messages will be delivered before delivery
- of any message from the remote node passed through the
- newly established connection.
- nodedown messages will not be delivered until all
- messages from the remote node that have been passed
- through the connection have been delivered.
+ nodeup messages are delivered before delivery
+ of any message from the remote node passed through the
+ newly established connection.
+ nodedown messages are not delivered until all
+ messages from the remote node that have been passed
+ through the connection have been delivered.
- Note, that this is not guaranteed for kernel
+
Notice that this is not guaranteed for Kernel
versions before 2.11.4.
- As of kernel version 2.11.4 subscriptions can also be
- made before the net_kernel server has been started,
- i.e., net_kernel:monitor_nodes/[1,2] does not return
+
As from Kernel version 2.11.4, subscriptions can also be
+ made before the net_kernel server is started, that is,
+ net_kernel:monitor_nodes/[1,2] does not return
ignored .
- As of kernel version 2.13, and erts version
+
As from Kernel version 2.13, and ERTS version
5.7, the following is guaranteed:
- nodeup messages will be delivered after the
- corresponding node appears in results from
- erlang:nodes/X .
- nodedown messages will be delivered after the
- corresponding node has disappeared in results from
- erlang:nodes/X .
+ nodeup messages are delivered after the
+ corresponding node appears in results from
+ erlang:nodes/X .
+ nodedown messages are delivered after the
+ corresponding node has disappeared in results from
+ erlang:nodes/X .
- Note, that this is not guaranteed for kernel
+
Notice that this is not guaranteed for Kernel
versions before 2.13.
The format of the node status change messages depends on
- Options . If Options is [], which is the default,
- the format is:
+ Options . If Options is
+ [] , which is the default, the format is as follows:
{nodeup, Node} | {nodedown, Node}
Node = node()
- If Options /= [] , the format is:
+ If Options is not [] , the format is
+ as follows:
{nodeup, Node, InfoList} | {nodedown, Node, InfoList}
Node = node()
InfoList = [{Tag, Val}]
InfoList is a list of tuples. Its contents depends on
Options , see below.
- Also, when OptionList == [] only visible nodes, that
+
Also, when OptionList == [] , only visible nodes, that
is, nodes that appear in the result of
- nodes/0 , are
- monitored.
+ erlang:nodes/0 ,
+ are monitored.
Option can be any of the following:
{node_type, NodeType}
-
-
Currently valid values for NodeType are:
+ Valid values for NodeType :
visible
- - Subscribe to node status change messages for visible
+
Subscribe to node status change messages for visible
nodes only. The tuple {node_type, visible} is
- included in InfoList .
+ included in InfoList .
hidden
- - Subscribe to node status change messages for hidden
+
Subscribe to node status change messages for hidden
nodes only. The tuple {node_type, hidden} is
- included in InfoList .
+ included in InfoList .
all
- - Subscribe to node status change messages for both
+
Subscribe to node status change messages for both
visible and hidden nodes. The tuple
- {node_type, visible | hidden} is included in
- InfoList .
+ {node_type, visible | hidden} is included in
+ InfoList .
nodedown_reason
-
The tuple {nodedown_reason, Reason} is included in
- InfoList in nodedown messages. Reason
- can be:
+ InfoList in nodedown messages.
+ Reason can be any of the following:
connection_setup_failed
- - The connection setup failed (after
nodeup
- messages had been sent).
+ The connection setup failed (after nodeup
+ messages were sent).
no_network
- - No network available.
+ No network is available.
net_kernel_terminated
- - The
net_kernel process terminated.
+ The net_kernel process terminated.
shutdown
- - Unspecified connection shutdown.
+ Unspecified connection shutdown.
connection_closed
- - The connection was closed.
+ The connection was closed.
disconnect
- - The connection was disconnected (forced from the
- current node).
+ The connection was disconnected (forced from the
+ current node).
net_tick_timeout
- - Net tick timeout.
+ Net tick time-out.
send_net_tick_failed
- - Failed to send net tick over the connection.
+ Failed to send net tick over the connection.
get_status_failed
- - Status information retrieval from the
Port
- holding the connection failed.
+ Status information retrieval from the Port
+ holding the connection failed.
-
-
- Get net_ticktime
-
- Gets net_ticktime (see
- kernel(6) ).
- Currently defined return values (Res ):
-
- NetTicktime
- -
-
net_ticktime is NetTicktime seconds.
-
- {ongoing_change_to, NetTicktime }
- -
-
net_kernel is currently changing
- net_ticktime to NetTicktime seconds.
-
- ignored
- -
-
The local node is not alive.
-
-
-
-
+
- Set net_ticktime
+ Set net_ticktime .
Sets net_ticktime (see
- kernel(6) ) to
- NetTicktime seconds. TransitionPeriod defaults
- to 60.
+ kernel(6) ) to
+ NetTicktime seconds.
+ TransitionPeriod defaults to 60 .
Some definitions:
- The minimum transition traffic interval (MTTI )
- -
-
minimum(NetTicktime , PreviousNetTicktime)*1000 div 4 milliseconds.
-
- The transition period
- -
-
The time of the least number of consecutive MTTI s
- to cover TransitionPeriod seconds following
- the call to set_net_ticktime/2 (i.e.
- ((TransitionPeriod *1000 - 1) div MTTI + 1)*MTTI
- milliseconds).
-
+ Minimum transition traffic interval (MTTI )
+ minimum(NetTicktime ,
+ PreviousNetTicktime)*1000 div 4 milliseconds.
+ Transition period
+ The time of the least number of consecutive MTTI s
+ to cover TransitionPeriod seconds following
+ the call to set_net_ticktime/2 (that is,
+ ((TransitionPeriod *1000 - 1) div MTTI + 1)*MTTI
+ milliseconds).
- If NetTicktime < PreviousNetTicktime]]> , the actual
- net_ticktime change will be done at the end of
- the transition period; otherwise, at the beginning. During
- the transition period, net_kernel will ensure that
- there will be outgoing traffic on all connections at least
+
If
+ ,
+ the net_ticktime change is done at the end of
+ the transition period; otherwise at the beginning. During
+ the transition period, net_kernel ensures that
+ there is outgoing traffic on all connections at least
every MTTI millisecond.
- The net_ticktime changes have to be initiated on all
+
The net_ticktime changes must be initiated on all
nodes in the network (with the same NetTicktime )
before the end of any transition period on any node;
- otherwise, connections may erroneously be disconnected.
+ otherwise connections can erroneously be disconnected.
Returns one of the following:
unchanged
-
-
net_ticktime already had the value of
- NetTicktime and was left unchanged.
+ net_ticktime already has the value of
+ NetTicktime and is left unchanged.
change_initiated
-
-
net_kernel has initiated the change of
- net_ticktime to NetTicktime seconds.
+ net_kernel initiated the change of
+ net_ticktime to NetTicktime
+ seconds.
{ongoing_change_to, NewNetTicktime }
-
-
The request was ignored; because,
- net_kernel was busy changing net_ticktime to
+
The request is ignored because
+ net_kernel is busy changing net_ticktime to
NewNetTicktime seconds.
+
start([Name]) -> {ok, pid()} | {error, Reason}
start([Name, NameType]) -> {ok, pid()} | {error, Reason}
start([Name, NameType, Ticktime]) -> {ok, pid()} | {error, Reason}
- Turn an Erlang runtime system into a distributed node
+ Turn an Erlang runtime system into a distributed node.
Name = atom()
NameType = shortnames | longnames
Reason = {already_started, pid()} | term()
- Note that the argument is a list with exactly one, two or
- three arguments. NameType defaults to longnames
- and Ticktime to 15000.
Turns a non-distributed node into a distributed node by
starting net_kernel and other necessary processes.
+ Notice that the argument is a list with exactly one, two, or
+ three arguments. NameType defaults to longnames
+ and Ticktime to 15000 .
+
- Turn a node into a non-distributed Erlang runtime system
+ Turn a node into a non-distributed Erlang runtime system.
Turns a distributed node into a non-distributed node. For
other nodes in the network, this is the same as the node
- going down. Only possible when the net kernel was started
- using start/1 , otherwise returns
- {error, not_allowed} . Returns {error, not_found}
- if the local node is not alive.
+ going down. Only possible when the net kernel was started using
+ start/1 ,
+ otherwise {error, not_allowed} is returned. Returns
+ {error, not_found} if the local node is not alive.
diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml
index 165160a909..2427aabcd5 100644
--- a/lib/kernel/doc/src/os.xml
+++ b/lib/kernel/doc/src/os.xml
@@ -29,98 +29,107 @@
os
- Operating System Specific Functions
+ Operating system-specific functions.
- The functions in this module are operating system specific.
- Careless use of these functions will result in programs that will
+
The functions in this module are operating system-specific.
+ Careless use of these functions results in programs that will
only run on a specific platform. On the other hand, with careful
- use these functions can be of help in enabling a program to run on
+ use, these functions can be of help in enabling a program to run on
most platforms.
- Execute a command in a shell of the target OS
+ Execute a command in a shell of the target OS.
- Executes Command in a command shell of the target OS,
- captures the standard output of the command and returns this
+
Executes Command in a command shell of the
+ target OS,
+ captures the standard output of the command, and returns this
result as a string. This function is a replacement of
- the previous unix:cmd/1 ; on a Unix platform they are
- equivalent.
- Examples:
+ the previous function unix:cmd/1 ; they are equivalent on a
+ Unix platform.
+ Examples:
LsOut = os:cmd("ls"), % on unix platform
DirOut = os:cmd("dir"), % on Win32 platform
- Note that in some cases, standard output of a command when
+
Notice that in some cases, standard output of a command when
called from another program (for example, os:cmd/1 )
- may differ, compared to the standard output of the command
+ can differ, compared with the standard output of the command
when called directly from an OS command shell.
+
- Absolute filename of a program
+ Absolute filename of a program.
- These two functions look up an executable program given its
- name and a search path, in the same way as the underlying
- operating system. find_executable/1 uses the current
- execution path (that is, the environment variable PATH on
+
These two functions look up an executable program, with the
+ specified name and a search path, in the same way as the underlying
+ OS. find_executable/1 uses the current
+ execution path (that is, the environment variable PATH on
Unix and Windows).
- Path , if given, should conform to the syntax of
- execution paths on the operating system. The absolute
- filename of the executable program Name is returned,
- or false if the program was not found.
+ Path , if specified, is to conform to the syntax
+ of execution paths on the OS. Returns the absolute filename of the
+ executable program Name ,
+ or false if the program is not found.
+
- List all environment variables
+ List all environment variables.
Returns a list of all environment variables.
- Each environment variable is given as a single string on
+ Each environment variable is expressed as a single string on
the format "VarName=Value" , where VarName is
the name of the variable and Value its value.
- If Unicode file name encoding is in effect (see the erl manual
- page ), the strings may contain characters with
- codepoints > 255.
+ If Unicode filename encoding is in effect (see the
+ erl manual
+ page ), the strings can contain characters with
+ codepoints > 255.
+
- Get the value of an environment variable
+ Get the value of an environment variable.
Returns the Value of the environment variable
- VarName , or false if the environment variable
- is undefined.
- If Unicode file name encoding is in effect (see the erl manual
- page ), the strings (both VarName and
- Value ) may contain characters with codepoints > 255.
+ VarName , or false if the environment
+ variable is undefined.
+ If Unicode filename encoding is in effect (see the
+ erl manual
+ page ), the strings VarName and
+ Value can contain characters with
+ codepoints > 255.
+
- Get the value of an environment variable
+ Get the value of an environment variable.
Returns the Value of the environment variable
- VarName , or DefaultValue if the environment variable
- is undefined.
- If Unicode file name encoding is in effect (see the erl manual
- page ), the strings (both VarName and
- Value ) may contain characters with codepoints > 255.
+ VarName , or DefaultValue if the
+ environment variable is undefined.
+ If Unicode filename encoding is in effect (see the
+ erl manual
+ page ), the strings VarName and
+ Value can contain characters with
+ codepoints > 255.
+
- Return the process identifier of the emulator process
+ Return the process identifier of the emulator
+ process.
Returns the process identifier of the current Erlang emulator
- in the format most commonly used by the operating system
- environment. Value is returned as a string containing
+ in the format most commonly used by the OS environment.
+ Returns Value as a string containing
the (usually) numerical identifier for a process. On Unix,
this is typically the return value of the getpid()
system call. On Windows,
@@ -128,88 +137,93 @@ DirOut = os:cmd("dir"), % on Win32 platform
system call is used.
+
- Set a new value for an environment variable
+ Set a new value for an environment variable.
- Sets a new Value for the environment variable
+
Sets a new Value for environment variable
VarName .
- If Unicode filename encoding is in effect (see the erl manual
- page ), the strings (both VarName and
- Value ) may contain characters with codepoints > 255.
- On Unix platforms, the environment will be set using UTF-8 encoding
- if Unicode file name translation is in effect. On Windows the
- environment is set using wide character interfaces.
+ If Unicode filename encoding is in effect (see the
+ erl manual
+ page ), the strings VarName and
+ Value can contain characters with
+ codepoints > 255.
+ On Unix platforms, the environment is set using UTF-8 encoding
+ if Unicode filename translation is in effect. On Windows, the
+ environment is set using wide character interfaces.
+
- Current OS system time
+ Current OS system time.
- Returns current
+
Returns the current
OS system time
in native
time unit .
-
- This time is not a monotonically increasing time.
+ This time is not a monotonically increasing time.
+
+
- Current OS system time
+ Current OS system time.
- Returns current
+
Returns the current
OS system time
converted into the Unit passed as argument.
-
- Calling os:system_time(Unit ) is equivalent to:
- erlang:convert_time_unit ( os:system_time() ,
+ Calling os:system_time(Unit ) is equivalent to
+ erlang:convert_time_unit (os:system_time() ,
native, Unit ) .
-
- This time is not a monotonically increasing time.
+ This time is not a monotonically increasing time.
+
+
- Current OS system time on the erlang:timestamp/0 format
+ Current OS system time on the erlang:timestamp/0 format.
Timestamp = {MegaSecs, Secs, MicroSecs}
- Returns current
+
Returns the current
OS system time
- in the same format as erlang:timestamp/0 .
- The tuple can be used together with the function
- calendar:now_to_universal_time/1
- or calendar:now_to_local_time/1 to
- get calendar time. Using the calendar time together with the MicroSecs part of the return
- tuple from this function allows you to log timestamps in high resolution and consistent with the
- time in the rest of the operating system.
- Example of code formatting a string in the format "DD Mon YYYY HH:MM:SS.mmmmmm", where
- DD is the day of month, Mon is the textual month name, YYYY is the year, HH:MM:SS is the time and
- mmmmmm is the microseconds in six positions:
-
+ in the same format as
+ erlang:timestamp/0 .
+ The tuple can be used together with function
+ calendar:now_to_universal_time/1
+ or calendar:now_to_local_time/1
+ to get calendar time. Using the calendar time, together with the
+ MicroSecs part of the return tuple from this function, allows
+ you to log time stamps in high resolution and consistent with the
+ time in the rest of the OS.
+ Example of code formatting a string in format
+ "DD Mon YYYY HH:MM:SS.mmmmmm", where DD is the day of month,
+ Mon is the textual month name, YYYY is the year, HH:MM:SS is the time,
+ and mmmmmm is the microseconds in six positions:
+
-module(print_time).
-export([format_utc_timestamp/0]).
format_utc_timestamp() ->
TS = {_,_,Micro} = os:timestamp(),
- {{Year,Month,Day},{Hour,Minute,Second}} =
- calendar:now_to_universal_time(TS),
+ {{Year,Month,Day},{Hour,Minute,Second}} =
+calendar:now_to_universal_time(TS),
Mstr = element(Month,{"Jan","Feb","Mar","Apr","May","Jun","Jul",
- "Aug","Sep","Oct","Nov","Dec"}),
+ "Aug","Sep","Oct","Nov","Dec"}),
io_lib:format("~2w ~s ~4w ~2w:~2..0w:~2..0w.~6..0w",
- [Day,Mstr,Year,Hour,Minute,Second,Micro]).
-
-
- The module above could be used in the following way:
-
+ [Day,Mstr,Year,Hour,Minute,Second,Micro]).
+ This module can be used as follows:
+
1> io:format("~s~n",[print_time:format_utc_timestamp()]).
-29 Apr 2009 9:55:30.051711
-
+29 Apr 2009 9:55:30.051711
OS system time can also be retreived by
-
1> T1 = os:perf_counter(1000),receive after 10000 -> ok end,T2 = os:perf_counter(1000).
176525861
2> T2 - T1.
@@ -236,41 +250,43 @@ format_utc_timestamp() ->
Returns the
On Unix,
Returns the
On Unix,
In Windows,
On Windows,
Think twice before using this function. Use the
-
Think twice before using this function. Use module
+
Deletes the environment variable
If Unicode filename encoding is in effect (see the
If Unicode filename encoding is in effect (see the
+
Returns the operating system version. +
Returns the OS version. On most systems, this function returns a tuple, but a string - will be returned instead if the system has versions which + is returned instead if the system has versions that cannot be expressed as three numbers.
Think twice before using this function. If you still need
diff --git a/lib/kernel/doc/src/pg2.xml b/lib/kernel/doc/src/pg2.xml
index 8c2fdb4cd3..0631b317b4 100644
--- a/lib/kernel/doc/src/pg2.xml
+++ b/lib/kernel/doc/src/pg2.xml
@@ -4,7 +4,7 @@
This module implements process groups. Each message may be sent
- to one, some, or all members of the group.
- This module implements process groups. Each message can be sent
+ to one, some, or all group members. A group of processes can be accessed by a common name. For
example, if there is a group named If a member terminates, it is automatically removed from the
- group.
-
If a member terminates, it is automatically removed from the group.
This module is used by the
This module is used by module
+
The name of a process group.
Creates a new, empty process group. The group is globally - visible on all nodes. If the group exists, nothing happens. -
+ visible on all nodes. If the group exists, nothing happens.Deletes a process group. -
+Deletes a process group.
This is a useful dispatch function which can be used from +
A useful dispatch function that can be used from client functions. It returns a process on the local node, if - such a process exist. Otherwise, it chooses one randomly. -
+ such a process exists. Otherwise, it selects one randomly.Returns all processes in the group
Returns all processes running on the local node in the
+ group
Returns all processes running on the local node in the
- group
Returns all processes in the group
Joins the process
Makes the process
Returns a list of all known groups. -
+ returned.Starts the pg2 server. Normally, the server does not need +
Starts the
Returns a list of all known groups.
The Kernel application has all the code necessary to run - the Erlang runtime system itself: file servers and code servers - and so on.
+This module contains services which are similar to remote - procedure calls. It also contains broadcast facilities and +
This module contains services similar to Remote + Procedure Calls. It also contains broadcast facilities and parallel evaluators. A remote procedure call is a method to call a function on a remote node and collect the answer. It is used for collecting information on a remote node, or for running a function with some specific side effects on the remote node.
As returned by
As returned by
+
Evaluates
Equivalent to
Evaluates
If the reply arrives after the call times out, no message
- will contaminate the caller's message queue, since this
- function spawns off a middleman process to act as (a void)
- destination for such an orphan reply. This feature also makes
- this function more expensive than
Broadcasts the message
Implements call streams with promises, a type of + RPC that does not suspend the caller until the result is + finished. Instead, a key is returned, which can be used + later to collect the value. The key can be viewed as a + promise to deliver the answer.
+In this case, the key
Like
Same as
Like
Same as
+
Implements call streams with promises, a type of - RPC which does not suspend the caller until the result is - finished. Instead, a key is returned which can be used at a - later stage to collect the value. The key can be viewed as a - promise to deliver the answer.
-In this case, the key
Evaluates
Returns the promised answer from a previous
-
Evaluates
If the reply arrives after the call times out, no message
+ contaminates the caller's message queue, as this
+ function spawns off a middleman process to act as (a void)
+ destination for such an orphan reply. This feature also makes
+ this function more expensive than
Equivalent to
Evaluates
Equivalent to
Evaluates
Equivalent to
This is a non-blocking version of
Can be used when interacting with servers called
+
Equivalent to
Equivalent to
Equivalent to
Equivalent to
Equivalent to
Equivalent to
In contrast to an RPC, a multicall is an RPC which is sent +
In contrast to an RPC, a multicall is an RPC that is sent concurrently from one client to multiple servers. This is - useful for collecting some information from a set of nodes, + useful for collecting information from a set of nodes, or for calling a function on a set of nodes to achieve some side effects. It is semantically the same as iteratively making a series of RPCs on all the nodes, but the multicall - is faster as all the requests are sent at the same time + is faster, as all the requests are sent at the same time and are collected one by one as they come back.
-The function evaluates
The function evaluates
The following example is useful when new object code is to - be loaded on all nodes in the network, and also indicates - some side effects RPCs may produce:
+ be loaded on all nodes in the network, and indicates + some side effects that RPCs can produce:
-%% Find object code for module Mod
-{Mod, Bin, File} = code:get_object_code(Mod),
+%% Find object code for module Mod
+{Mod, Bin, File} = code:get_object_code(Mod),
-%% and load it on all nodes including this one
+%% and load it on all nodes including this one
{ResL, _} = rpc:multicall(code, load_binary, [Mod, File, Bin]),
%% and then maybe check the ResL list.
Evaluates
Equivalent to
Evaluates
Equivalent to
Broadcasts the message
Equivalent to
Equivalent to
Non-blocking version of
+
Broadcasts the message
Returns
The function is synchronous in the sense that it is known - that all servers have received the message when the call - returns. It is not possible to know that the servers have - actually processed the message.
-Any further messages sent to the servers, after this - function has returned, will be received by all servers after - this message.
+Evaluates, for every tuple in
This function can be used when interacting with a server
- called
The function returns the answer
Location transparent version of the BIF
+
Equivalent to
Location transparent version of the BIF
+
This function can be used when interacting with servers
- called
Evaluates
This function is deprecated. Use
-
Deprecated. Use
+
In Erlang/OTP R6B and earlier releases,
For every tuple in
Equivalent to
Evaluates
Broadcasts the message
Returns
The function is synchronous in the sense that it is known + that all servers have received the message when the call + returns. It is not possible to know that the servers have + processed the message.
+Any further messages sent to the servers, after this + function has returned, are received by all servers after + this message.
Location transparent version of the BIF
-
Can be used when interacting with a server called
+
The function returns the answer
Location transparent version of the BIF
-
Returns the promised answer from a previous
+
Sequential tracing makes it possible to trace all messages
resulting from one initial message. Sequential tracing is
- completely independent of the ordinary tracing in Erlang, which
- is controlled by the
The implementation of sequential tracing is in beta status. - This means that the programming interface still might undergo - minor adjustments (possibly incompatible) based on feedback - from users.
-The format of the messages are:
+The format of the messages is one of the following, depending on if
+ flag
{seq_trace, Label, SeqTraceInfo, TimeStamp}
or
{seq_trace, Label, SeqTraceInfo}
- depending on whether the
Where:
Label = int()
TimeStamp = {Seconds, Milliseconds, Microseconds}
Seconds = Milliseconds = Microseconds = int()
- The
Used when a process
Used when a process
Used when a process
Integer
Integer
Sequential tracing is a way to trace a sequence of messages sent between different local or remote processes, where the sequence - is initiated by one single message. In short it works like this:
+ is initiated by a single message. In short, it works as follows:Each process has a trace token, which can be empty or
- not empty. When not empty the trace token can be seen as
+ not empty. When not empty, the trace token can be seen as
the tuple
In order to start a sequential trace the user must explicitly set +
To start a sequential trace, the user must explicitly set the trace token in the process that will send the first message in a sequence.
The trace token of a process is set each time the process matches a message in a receive statement, according to the trace token carried by the received message, empty or not.
-On each Erlang node a process can be set as the system tracer. This process will receive trace messages each time +
On each Erlang node, a process can be set as the system tracer.
+ This process receives trace messages each time
a message with a trace token is sent or received (if the trace
token flag
The system tracer will only receive those trace events that +
The system tracer only receives those trace events that occur locally within the Erlang node. To get the whole picture - of a sequential trace that involves processes on several Erlang + of a sequential trace, involving processes on many Erlang nodes, the output from the system tracer on each involved node - must be merged (off line).
+ must be merged (offline).In the following sections Sequential Tracing and its most - fundamental concepts are described.
+The following sections describe sequential tracing and its most + fundamental concepts.
Each process has a current trace token. Initially the token is +
Each process has a current trace token. Initially, the token is empty. When the process sends a message to another process, a - copy of the current token will be sent "invisibly" along with + copy of the current token is sent "invisibly" along with the message.
-The current token of a process is set in two ways, either
-The current token of a process is set in one of the following two + ways:
+explicitly by the process itself, through a call to
-
Explicitly by the process itself, through a call to
+
when a message is received.
+When a message is received
In both cases the current token will be set. In particular, if - the token of a message received is empty, the current token of +
In both cases, the current token is set. In particular, if + the token of a received message is empty, the current token of the process is set to empty.
-A trace token contains a label, and a set of flags. Both - the label and the flags are set in 1 and 2 above.
+A trace token contains a label and a set of flags. Both + the label and the flags are set in both alternatives above.
The trace token contains a component which is called
-
The trace token contains a component called
+
The algorithm for updating
Let each process have two counters
Let each process have two counters,
When the process is about to send a message and the trace token is not empty.
+When the process is about to send a message and the trace token + is not empty.
Let the serial of the trace token be
-
-
-
+curr_cnt := curr_cnt + 1 +tprev := prev_cnt +tcurr := curr_cnt
The trace token with
When the process calls
The same algorithm as for send above.
+When the process calls
The algorithm is the same as for send above.
When a message is received and contains a nonempty trace token.
+When a message is received and contains a non-empty trace + token.
The process trace token is set to the trace token from the message.
Let the serial of the trace token be
-
-
-
-
+
+ curr_cnt := tcurr
+prev_cnt := tcurr
The
The performance degradation for a system which is enabled for - Sequential Tracing is negligible as long as no tracing is - activated. When tracing is activated there will of course be an - extra cost for each traced message but all other messages will be +
The performance degradation for a system that is enabled for + sequential tracing is negligible as long as no tracing is + activated. When tracing is activated, there is an + extra cost for each traced message, but all other messages are unaffected.
Sequential tracing is not performed across ports.
If the user for some reason wants to pass the trace token to a
- port this has to be done manually in the code of the port
+ port, this must be done manually in the code of the port
controlling process. The port controlling processes have to check
the appropriate sequential trace settings (as obtained from
-
Similarly, for messages received from a port, a port controller
- has to retrieve trace specific information, and set appropriate
+ has to retrieve trace-specific information, and set appropriate
sequential trace flags through calls to
Sequential tracing between nodes is performed transparently.
- This applies to C-nodes built with Erl_Interface too. A C-node
- built with Erl_Interface only maintains one trace token, which
- means that the C-node will appear as one process from
+ This applies to C-nodes built with
In order to be able to perform sequential tracing between +
To be able to perform sequential tracing between distributed Erlang nodes, the distribution protocol has been - extended (in a backward compatible way). An Erlang node which - supports sequential tracing can communicate with an older - (OTP R3B) node but messages passed within that node can of course + extended (in a backward compatible way). An Erlang node + supporting sequential tracing can communicate with an older + (Erlang/OTP R3B) node but messages passed within that node can not be traced.
The example shown here will give rough idea of how the new - primitives can be used and what kind of output it will produce.
-Assume that we have an initiating process with +
This example gives a rough idea of how the new + primitives can be used and what kind of output it produces.
+Assume that you have an initiating process with
-module(seqex).
@@ -463,8 +467,8 @@ loop() ->
PortController ! {ack,Ack}
end,
loop().
- A possible output from the system's sequential_tracer (inspired - by AXE-10 and MD-110) could look like:
+A possible output from the system's
17:<0.30.0> Info {0,1} WITH
"**** Trace Started ****"
@@ -475,7 +479,7 @@ loop() ->
17:<0.30.0> Received {2,4} FROM <0.31.0> WITH
{ack,{received,the_message}}
The implementation of a system tracer process that produces - the printout above could look like this:
+ this printout can look like this:
tracer() ->
receive
@@ -502,16 +506,15 @@ print_trace({'receive',Serial,From,To,Message}) ->
print_trace({send,Serial,From,To,Message}) ->
io:format("~p Sent ~p TO ~p WITH~n~p~n",
[From,Serial,To,Message]).
- The code that creates a process that runs the tracer function - above and sets that process as the system tracer could look like - this:
+The code that creates a process that runs this tracer function + and sets that process as the system tracer can look like this:
start() ->
Pid = spawn(?MODULE,tracer,[]),
seq_trace:set_system_tracer(Pid), % set Pid as the system tracer
ok.
- With a function like
With a function like
test() ->
P = spawn(?MODULE, loop, [port]),
diff --git a/lib/kernel/doc/src/user.xml b/lib/kernel/doc/src/user.xml
index 24119bea82..440b7878e8 100644
--- a/lib/kernel/doc/src/user.xml
+++ b/lib/kernel/doc/src/user.xml
@@ -27,13 +27,13 @@
user
Robert Virding
1
- 96-10-10
+ 1996-10-10
A
user
- Standard I/O Server
+ Standard I/O server.
- user is a server which responds to all the messages
+
user is a server that responds to all messages
defined in the I/O interface. The code in user.erl can be
used as a model for building alternative I/O servers.
diff --git a/lib/kernel/doc/src/wrap_log_reader.xml b/lib/kernel/doc/src/wrap_log_reader.xml
index c021f42cac..7fb9c1c023 100644
--- a/lib/kernel/doc/src/wrap_log_reader.xml
+++ b/lib/kernel/doc/src/wrap_log_reader.xml
@@ -4,7 +4,7 @@
- 1998 2013
+ 1998 2016
Ericsson AB. All Rights Reserved.
@@ -26,39 +26,43 @@
Esko Vierumäki
Esko Vierumäki
- nobody
- no
- 98-09-21
+
+
+ 1998-09-21
A
wrap_log_reader.sgml
wrap_log_reader
- A function to read internally formatted wrap disk logs
+ A service to read internally formatted wrap disk logs.
+
- wrap_log_reader is a function to read internally formatted
- wrap disk logs, refer to disk_log(3). wrap_log_reader does not
- interfere with disk_log activities; there is however a known bug in this
- version of the wrap_log_reader , see chapter bugs below.
-
- A wrap disk log file consists of several files, called index files.
- A log file can be opened and closed. It is also possible to open just one index file
- separately. If an non-existent or a non-internally formatted file is opened,
- an error message is returned. If the file is corrupt, no attempt to repair it
- will be done but an error message is returned.
-
- If a log is configured to be distributed, there is a possibility that all items
- are not loggen on all nodes. wrap_log_reader does only read the log on
- the called node, it is entirely up to the user to be sure that all items are read.
-
+ This module makes it possible to read internally formatted
+ wrap disk logs, see
+ disk_log(3) .
+ wrap_log_reader does not
+ interfere with disk_log activities; there is however a bug in this
+ version of the wrap_log_reader , see section
+ Known Limitations .
+ A wrap disk log file consists of many files, called index files. A log
+ file can be opened and closed. Also, a single index file can be opened
+ separately. If a non-existent or non-internally formatted file is opened,
+ an error message is returned. If the file is corrupt, no attempt is made
+ to repair it, but an error message is returned.
+ If a log is configured to be distributed, it is possible that all items
+ are not logged on all nodes. wrap_log_reader only reads the log on
+ the called node; it is up to the user to be sure that all items
+ are read.
+
- Continuation returned by
- open/1,2 or chunk/1,2 .
+
+ Continuation returned by open/1,2 or chunk/1,2 .
+
@@ -66,87 +70,83 @@
Read a chunk of objects written to a wrap log.
- This function makes it possible to efficiently read the
- terms which have been appended to a log. It minimises disk
- I/O by reading large 8K chunks from the file.
-
- The first time chunk is called an initial
- continuation returned from the open/1 , open/2 must be provided.
-
+ Enables to efficiently read the
+ terms that are appended to a log. Minimises disk
+ I/O by reading 64 kilobyte chunks from the file.
+ The first time chunk() is called, an initial
+ continuation returned from open/1 or open/2 must be
+ provided.
When chunk/3 is called, N controls the
maximum number of terms that are read from the log in each
- chunk. Default is infinity , which means that all the
+ chunk. Defaults to infinity , which means that all the
terms contained in the 8K chunk are read. If less than
- N terms are returned, this does not necessarily mean
- that end of file is reached.
-
- The chunk function returns a tuple
- {Continuation2 , Terms } , where Terms is a list
+ N terms are returned, this does not necessarily
+ mean that end of file is reached.
+ Returns a tuple {Continuation2 ,
+ Terms } , where Terms is a list
of terms found in the log. Continuation2 is yet
- another continuation which must be passed on into any
- subsequent calls to chunk . With a series of calls to
- chunk it is then possible to extract all terms from a
- log.
-
- The chunk function returns a tuple
- {Continuation2 , Terms , Badbytes } if the log is opened
- in read only mode and the read chunk is corrupt. Badbytes
+ another continuation that must be passed on to any
+ subsequent calls to chunk() . With a series of calls to
+ chunk() , it is then possible to extract all terms from a log.
+ Returns a tuple {Continuation2 ,
+ Terms , Badbytes } if the log is opened
+ in read only mode and the read chunk is corrupt.
+ Badbytes
indicates the number of non-Erlang terms found in the chunk.
- Note also that the log is not repaired.
-
- chunk returns {Continuation2 , eof} when the end of the log is
- reached, and {error, Reason } if an error occurs.
-
- The returned continuation may or may not be valid in the next call to
- chunk . This is because the log may wrap and delete
- the file into which the continuation points. To make sure
- this does not happen, the log can be blocked during the
- search.
-
+ Notice that the log is not repaired.
+ Returns {Continuation2 , eof} when
+ the end of the log is reached, and {error, Reason }
+ if an error occurs.
+ The returned continuation either is or is not valid in the next call
+ to this function. This is because the log can wrap and delete
+ the file into which the continuation points. To ensure
+ this does not occur, the log can be blocked during the search.
+
- Close a log
+ Close a log.
- This function closes a log file properly.
-
+ Closes a log file properly.
+
- Open a log file
+ Open a log file.
- Filename specifies the name of the file which is to be read.
- N specifies the index of the file which is to be read.
- If N is omitted the whole wrap log file will be read; if it
- is specified only the specified index file will be read.
-
- The open function returns {ok, Continuation } if the
- log/index file was successfully opened. The Continuation
- is to be used when chunking or closing the file.
-
- The function returns {error, Reason } for all errors.
-
+ Filename specifies the name of the file to be
+ read.
+ N specifies the index of the file to be read.
+ If N is omitted, the whole wrap log file is read;
+ if it is specified, only the specified index file is read.
+ Returns {ok, Continuation } if the
+ log/index file is opened successfully.
+ Continuation
+ is to be used when chunking or closing the file.
+ Returns {error, Reason } for all errors.
- Bugs
- This version of the wrap_log_reader does not detect if the disk_log
- wraps to a new index file between a wrap_log_reader:open and the first
- wrap_log_reader:chunk .
- In this case the chuck will actually read the last logged items in the log file,
- because the opened index file was truncated by the disk_log .
-
+ Known Limitations
+
+ This version of wrap_log_reader does not detect if
+ disk_log wraps to a new index file between a call to
+ wrap_log_reader:open() and the first call to
+ wrap_log_reader:chunk() .
+ If this occurs, the call to chunk() reads the last logged
+ items in the log file, as the opened index file was truncated by
+ disk_log .
See Also
- disk_log(3)
+ disk_log(3)
diff --git a/lib/kernel/doc/src/zlib_stub.xml b/lib/kernel/doc/src/zlib_stub.xml
index d1823b01aa..ea2a6af2bd 100644
--- a/lib/kernel/doc/src/zlib_stub.xml
+++ b/lib/kernel/doc/src/zlib_stub.xml
@@ -31,13 +31,9 @@
A
zlib
- Zlib Compression interface.
-
-
- The module zlib is moved to the runtime system
- application. Please see zlib(3) in the
- erts reference manual instead.
-
-
+ Zlib compression interface.
+
+ This module is moved to the
+ ERTS application.
+
--
cgit v1.2.3
From 20ca1514787110037079e39bd10f00e0e3957ea7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?=
Date: Wed, 23 Mar 2016 12:42:55 +0100
Subject: code: Remove 'bad_path' error code from set_path/1
code:set_path/1 no longer returns {error,bad_path} (an exception
will be thrown instead).
---
lib/kernel/doc/src/code.xml | 2 --
1 file changed, 2 deletions(-)
(limited to 'lib/kernel/doc/src')
diff --git a/lib/kernel/doc/src/code.xml b/lib/kernel/doc/src/code.xml
index 575f2f0b51..7598b22d79 100644
--- a/lib/kernel/doc/src/code.xml
+++ b/lib/kernel/doc/src/code.xml
@@ -330,8 +330,6 @@ zip:create("mnesia-4.4.7.ez",
If successful
{error, bad_directory}
If any Dir is not a directory name
- {error, bad_path}
- If the argument is invalid
--
cgit v1.2.3