Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > ca236e080672a3aa5beda2fe21b8473d > files > 123

erlang-doc-21.2.5-1.mga7.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:erl="http://erlang.org" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../otp_doc.css" type="text/css">
<title>Erlang -- Ports and Port Drivers</title>
</head>
<body>
<div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<div class="erlang-logo-wrapper"><a href="../index.html"><img alt="Erlang Logo" src="../erlang-logo.png" class="erlang-logo"></a></div>
<p class="section-title">Erlang Reference Manual</p>
<p class="section-subtitle">User's Guide</p>
<p class="section-version">Version 10.2.3</p>
<ul class="panel-sections">
<li><a href="users_guide.html">User's Guide</a></li>
<li><a href="../pdf/otp-system-documentation-10.2.3.pdf">PDF</a></li>
<li><a href="../index.html">Top</a></li>
</ul>
<ul class="expand-collapse-items">
<li><a href="javascript:openAllFlips()">Expand All</a></li>
<li><a href="javascript:closeAllFlips()">Contract All</a></li>
</ul>
<h3>Chapters</h3>
<ul class="flipMenu" imagepath="../js/flipmenu">
<li id="no" title="Introduction" expanded="false">Introduction<ul>
<li><a href="introduction.html">
              Top of chapter
            </a></li>
<li title="Purpose"><a href="introduction.html#purpose">Purpose</a></li>
<li title="Prerequisites"><a href="introduction.html#prerequisites">Prerequisites</a></li>
<li title="Document Conventions"><a href="introduction.html#document-conventions">Document Conventions</a></li>
<li title="Complete List of BIFs"><a href="introduction.html#complete-list-of-bifs">Complete List of BIFs</a></li>
<li title="Reserved Words"><a href="introduction.html#reserved-words">Reserved Words</a></li>
</ul>
</li>
<li id="no" title="Character Set and Source File Encoding" expanded="false">Character Set and Source File Encoding<ul>
<li><a href="character_set.html">
              Top of chapter
            </a></li>
<li title="Character Set"><a href="character_set.html#character-set">Character Set</a></li>
<li title="Source File Encoding"><a href="character_set.html#source-file-encoding">Source File Encoding</a></li>
</ul>
</li>
<li id="no" title="Data Types" expanded="false">Data Types<ul>
<li><a href="data_types.html">
              Top of chapter
            </a></li>
<li title="Terms"><a href="data_types.html#terms">Terms</a></li>
<li title="Number"><a href="data_types.html#number">Number</a></li>
<li title="Atom"><a href="data_types.html#atom">Atom</a></li>
<li title="Bit Strings and Binaries"><a href="data_types.html#bit-strings-and-binaries">Bit Strings and Binaries</a></li>
<li title="Reference"><a href="data_types.html#reference">Reference</a></li>
<li title="Fun"><a href="data_types.html#fun">Fun</a></li>
<li title="Port Identifier"><a href="data_types.html#port-identifier">Port Identifier</a></li>
<li title="Pid"><a href="data_types.html#pid">Pid</a></li>
<li title="Tuple"><a href="data_types.html#tuple">Tuple</a></li>
<li title="Map"><a href="data_types.html#map">Map</a></li>
<li title="List"><a href="data_types.html#list">List</a></li>
<li title="String"><a href="data_types.html#string">String</a></li>
<li title="Record"><a href="data_types.html#record">Record</a></li>
<li title="Boolean"><a href="data_types.html#boolean">Boolean</a></li>
<li title="Escape Sequences"><a href="data_types.html#escape-sequences">Escape Sequences</a></li>
<li title="Type Conversions"><a href="data_types.html#type-conversions">Type Conversions</a></li>
</ul>
</li>
<li id="no" title="Pattern Matching" expanded="false">Pattern Matching<ul>
<li><a href="patterns.html">
              Top of chapter
            </a></li>
<li title="Pattern Matching"><a href="patterns.html#pattern-matching">Pattern Matching</a></li>
</ul>
</li>
<li id="no" title="Modules" expanded="false">Modules<ul>
<li><a href="modules.html">
              Top of chapter
            </a></li>
<li title="Module Syntax"><a href="modules.html#module-syntax">Module Syntax</a></li>
<li title="Module Attributes"><a href="modules.html#module-attributes">Module Attributes</a></li>
<li title="Comments"><a href="modules.html#comments">Comments</a></li>
<li title="module_info/0 and module_info/1 functions"><a href="modules.html#module_info-0-and-module_info-1-functions">module_info/0 and module_info/1 functions</a></li>
</ul>
</li>
<li id="no" title="Functions" expanded="false">Functions<ul>
<li><a href="functions.html">
              Top of chapter
            </a></li>
<li title="Function Declaration Syntax"><a href="functions.html#function-declaration-syntax">Function Declaration Syntax</a></li>
<li title="Function Evaluation"><a href="functions.html#function-evaluation">Function Evaluation</a></li>
<li title="Tail recursion"><a href="functions.html#tail-recursion">Tail recursion</a></li>
<li title="Built-In Functions (BIFs)"><a href="functions.html#built-in-functions--bifs-">Built-In Functions (BIFs)</a></li>
</ul>
</li>
<li id="no" title="Types and Function Specifications" expanded="false">Types and Function Specifications<ul>
<li><a href="typespec.html">
              Top of chapter
            </a></li>
<li title="The Erlang Type Language"><a href="typespec.html#the-erlang-type-language">The Erlang Type Language</a></li>
<li title="Types and their Syntax"><a href="typespec.html#types-and-their-syntax">Types and their Syntax</a></li>
<li title="Type Declarations of User-Defined Types"><a href="typespec.html#type-declarations-of-user-defined-types">Type Declarations of User-Defined Types</a></li>
<li title="Type Information in Record Declarations"><a href="typespec.html#type-information-in-record-declarations">Type Information in Record Declarations</a></li>
<li title="Specifications for Functions"><a href="typespec.html#specifications-for-functions">Specifications for Functions</a></li>
</ul>
</li>
<li id="no" title="Expressions" expanded="false">Expressions<ul>
<li><a href="expressions.html">
              Top of chapter
            </a></li>
<li title="Expression Evaluation"><a href="expressions.html#expression-evaluation">Expression Evaluation</a></li>
<li title="Terms"><a href="expressions.html#terms">Terms</a></li>
<li title="Variables"><a href="expressions.html#variables">Variables</a></li>
<li title="Patterns"><a href="expressions.html#patterns">Patterns</a></li>
<li title="Match"><a href="expressions.html#match">Match</a></li>
<li title="Function Calls"><a href="expressions.html#function-calls">Function Calls</a></li>
<li title="If"><a href="expressions.html#if">If</a></li>
<li title="Case"><a href="expressions.html#case">Case</a></li>
<li title="Send"><a href="expressions.html#send">Send</a></li>
<li title="Receive"><a href="expressions.html#receive">Receive</a></li>
<li title="Term Comparisons"><a href="expressions.html#term-comparisons">Term Comparisons</a></li>
<li title="Arithmetic Expressions"><a href="expressions.html#arithmetic-expressions">Arithmetic Expressions</a></li>
<li title="Boolean Expressions"><a href="expressions.html#boolean-expressions">Boolean Expressions</a></li>
<li title="Short-Circuit Expressions"><a href="expressions.html#short-circuit-expressions">Short-Circuit Expressions</a></li>
<li title="List Operations"><a href="expressions.html#list-operations">List Operations</a></li>
<li title="Map Expressions"><a href="expressions.html#map-expressions">Map Expressions</a></li>
<li title="Bit Syntax Expressions"><a href="expressions.html#bit-syntax-expressions">Bit Syntax Expressions</a></li>
<li title="Fun Expressions"><a href="expressions.html#fun-expressions">Fun Expressions</a></li>
<li title="Catch and Throw"><a href="expressions.html#catch-and-throw">Catch and Throw</a></li>
<li title="Try"><a href="expressions.html#try">Try</a></li>
<li title="Parenthesized Expressions"><a href="expressions.html#parenthesized-expressions">Parenthesized Expressions</a></li>
<li title="Block Expressions"><a href="expressions.html#block-expressions">Block Expressions</a></li>
<li title="List Comprehensions"><a href="expressions.html#list-comprehensions">List Comprehensions</a></li>
<li title="Bit String Comprehensions"><a href="expressions.html#bit-string-comprehensions">Bit String Comprehensions</a></li>
<li title="Guard Sequences"><a href="expressions.html#guard-sequences">Guard Sequences</a></li>
<li title="Operator Precedence"><a href="expressions.html#operator-precedence">Operator Precedence</a></li>
</ul>
</li>
<li id="no" title="Preprocessor" expanded="false">Preprocessor<ul>
<li><a href="macros.html">
              Top of chapter
            </a></li>
<li title="File Inclusion"><a href="macros.html#file-inclusion">File Inclusion</a></li>
<li title="Defining and Using Macros"><a href="macros.html#defining-and-using-macros">Defining and Using Macros</a></li>
<li title="Predefined Macros"><a href="macros.html#predefined-macros">Predefined Macros</a></li>
<li title="Macros Overloading"><a href="macros.html#macros-overloading">Macros Overloading</a></li>
<li title="Flow Control in Macros"><a href="macros.html#flow-control-in-macros">Flow Control in Macros</a></li>
<li title="-error() and -warning() directives"><a href="macros.html#-error---and--warning---directives">-error() and -warning() directives</a></li>
<li title="Stringifying Macro Arguments"><a href="macros.html#stringifying-macro-arguments">Stringifying Macro Arguments</a></li>
</ul>
</li>
<li id="no" title="Records" expanded="false">Records<ul>
<li><a href="records.html">
              Top of chapter
            </a></li>
<li title="Defining Records"><a href="records.html#defining-records">Defining Records</a></li>
<li title="Creating Records"><a href="records.html#creating-records">Creating Records</a></li>
<li title="Accessing Record Fields"><a href="records.html#accessing-record-fields">Accessing Record Fields</a></li>
<li title="Updating Records"><a href="records.html#updating-records">Updating Records</a></li>
<li title="Records in Guards"><a href="records.html#records-in-guards">Records in Guards</a></li>
<li title="Records in Patterns"><a href="records.html#records-in-patterns">Records in Patterns</a></li>
<li title="Nested Records"><a href="records.html#nested-records">Nested Records</a></li>
<li title="Internal Representation of Records"><a href="records.html#internal-representation-of-records">Internal Representation of Records</a></li>
</ul>
</li>
<li id="no" title="Errors and Error Handling" expanded="false">Errors and Error Handling<ul>
<li><a href="errors.html">
              Top of chapter
            </a></li>
<li title="Terminology"><a href="errors.html#terminology">Terminology</a></li>
<li title="Exceptions"><a href="errors.html#exceptions">Exceptions</a></li>
<li title="Handling of Run-time Errors in Erlang"><a href="errors.html#handling-of-run-time-errors-in-erlang">Handling of Run-time Errors in Erlang</a></li>
<li title="Exit Reasons"><a href="errors.html#exit-reasons">Exit Reasons</a></li>
</ul>
</li>
<li id="no" title="Processes" expanded="false">Processes<ul>
<li><a href="processes.html">
              Top of chapter
            </a></li>
<li title="Processes"><a href="processes.html#processes">Processes</a></li>
<li title="Process Creation"><a href="processes.html#process-creation">Process Creation</a></li>
<li title="Registered Processes"><a href="processes.html#registered-processes">Registered Processes</a></li>
<li title="Process Termination"><a href="processes.html#process-termination">Process Termination</a></li>
<li title="Message Sending"><a href="processes.html#message-sending">Message Sending</a></li>
<li title="Links"><a href="processes.html#links">Links</a></li>
<li title="Error Handling"><a href="processes.html#error-handling">Error Handling</a></li>
<li title="Monitors"><a href="processes.html#monitors">Monitors</a></li>
<li title="Process Dictionary"><a href="processes.html#process-dictionary">Process Dictionary</a></li>
</ul>
</li>
<li id="no" title="Distributed Erlang" expanded="false">Distributed Erlang<ul>
<li><a href="distributed.html">
              Top of chapter
            </a></li>
<li title="Distributed Erlang System"><a href="distributed.html#distributed-erlang-system">Distributed Erlang System</a></li>
<li title="Nodes"><a href="distributed.html#nodes">Nodes</a></li>
<li title="Node Connections"><a href="distributed.html#node-connections">Node Connections</a></li>
<li title="epmd"><a href="distributed.html#epmd">epmd</a></li>
<li title="Hidden Nodes"><a href="distributed.html#hidden-nodes">Hidden Nodes</a></li>
<li title="C Nodes"><a href="distributed.html#c-nodes">C Nodes</a></li>
<li title="Security"><a href="distributed.html#security">Security</a></li>
<li title="Distribution BIFs"><a href="distributed.html#distribution-bifs">Distribution BIFs</a></li>
<li title="Distribution Command-Line Flags"><a href="distributed.html#distribution-command-line-flags">Distribution Command-Line Flags</a></li>
<li title="Distribution Modules"><a href="distributed.html#distribution-modules">Distribution Modules</a></li>
</ul>
</li>
<li id="no" title="Compilation and Code Loading" expanded="false">Compilation and Code Loading<ul>
<li><a href="code_loading.html">
              Top of chapter
            </a></li>
<li title="Compilation"><a href="code_loading.html#compilation">Compilation</a></li>
<li title="Code Loading"><a href="code_loading.html#code-loading">Code Loading</a></li>
<li title="Code Replacement"><a href="code_loading.html#code-replacement">Code Replacement</a></li>
<li title="Running a Function When a Module is Loaded"><a href="code_loading.html#running-a-function-when-a-module-is-loaded">Running a Function When a Module is Loaded</a></li>
</ul>
</li>
<li id="loadscrollpos" title="Ports and Port Drivers" expanded="true">Ports and Port Drivers<ul>
<li><a href="ports.html">
              Top of chapter
            </a></li>
<li title="Ports"><a href="ports.html#ports">Ports</a></li>
<li title="Port Drivers"><a href="ports.html#port-drivers">Port Drivers</a></li>
<li title="Port BIFs"><a href="ports.html#port-bifs">Port BIFs</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<h1>15 Ports and Port Drivers</h1>
  
  <p>Examples of how to use ports and port drivers are provided in
    <span class="bold_code bc-13"><a href="javascript:erlhref('../../','doc/tutorial','introduction.html#interoperability%20tutorial');">Interoperability Tutorial</a></span>.
    For information about the BIFs mentioned, see the
    <span class="bold_code bc-18"><a href="javascript:erlhref('../../','erts','erlang.html');">erlang(3)</a></span> manual
    page in ERTS.</p>

  <h3><span onMouseOver="document.getElementById('ghlink-ports-idm281472323680088').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ports-idm281472323680088').style.visibility = 'hidden';"><span id="ghlink-ports-idm281472323680088" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/system/doc/reference_manual/ports.xml#L39" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ports" href="#ports">15.1 
          Ports</a></span></h3>
    
    <p><strong>Ports</strong> provide the basic mechanism for communication
      with the external world, from Erlang's point of view. They
      provide a byte-oriented interface to an external program. When a
      port has been created, Erlang can communicate with it by sending
      and receiving lists of bytes, including binaries.</p>
    <p>The Erlang process creating a port is said to be
      the <strong>port owner</strong>, or the <strong>connected process</strong> of
      the port. All communication to and from the port must go through
      the port owner. If the port owner terminates, so does the port
      (and the external program, if it is written correctly).</p>
    <p>The external program resides in another OS process. By default,
      it reads from standard input (file descriptor 0) and writes
      to standard output (file descriptor 1). The external program
      is to terminate when the port is closed.</p>
  

  <h3><span onMouseOver="document.getElementById('ghlink-port-drivers-idm281472323675608').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-port-drivers-idm281472323675608').style.visibility = 'hidden';"><span id="ghlink-port-drivers-idm281472323675608" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/system/doc/reference_manual/ports.xml#L57" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="port-drivers" href="#port-drivers">15.2 
          Port Drivers</a></span></h3>
    
    <p>It is possible to write a driver in C according to certain
      principles and dynamically link it to the Erlang runtime system.
      The linked-in driver looks like a port from the Erlang
      programmer's point of view and is called a <strong>port driver</strong>.</p>
    <div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
      <p>An erroneous port driver causes the entire Erlang runtime
        system to leak memory, hang or crash.</p>
    </p></div>
</div>
    <p>For information about port drivers, see the
      <span class="bold_code bc-18"><a href="javascript:erlhref('../../','erts','erl_driver.html');">erl_driver(4)</a></span>
      manual page in ERTS,
      <span class="bold_code bc-18"><a href="javascript:erlhref('../../','erts','driver_entry.html');">driver_entry(1)</a></span>
      manual page in ERTS, and
      <span class="bold_code bc-18"><a href="javascript:erlhref('../../','kernel','erl_ddll.html');">erl_ddll(3)</a></span>
      manual page in Kernel.</p>
  

  <h3><span onMouseOver="document.getElementById('ghlink-port-bifs-idm281472323669624').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-port-bifs-idm281472323669624').style.visibility = 'hidden';"><span id="ghlink-port-bifs-idm281472323669624" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/system/doc/reference_manual/ports.xml#L76" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="port-bifs" href="#port-bifs">15.3 
          Port BIFs</a></span></h3>
    
    <p>To create a port:</p>
    <div class="doc-table-wrapper">
<table class="doc-table"><tr>
        <td align="left" valign="middle"><span class="code">open_port(PortName, PortSettings</span></td>
        <td align="left" valign="middle">Returns a port identifier
        <span class="code">Port</span> as the result of opening a new Erlang port.
        Messages can be sent to, and received from, a port identifier,
        just like a pid. Port identifiers can also be linked to
        using <span class="code">link/1</span>, or registered under a name using
        <span class="code">register/2</span>.</td>
      </tr></table>
<p class="doc-table-caption">Table
        15.1:
         
        Port Creation BIF</p>
</div>
    <p><span class="code">PortName</span> is usually a tuple <span class="code">{spawn,Command}</span>, where
      the string <span class="code">Command</span> is the name of the external program.
      The external program runs outside the Erlang workspace, unless a
      port driver with the name <span class="code">Command</span> is found. If <span class="code">Command</span>
      is found, that driver is started.</p>
    <p><span class="code">PortSettings</span> is a list of settings (options) for the port.
      The list typically contains at least a tuple <span class="code">{packet,N}</span>,
      which specifies that data sent between the port and the external
      program are preceded by an N-byte length indicator. Valid values
      for N are 1, 2, or 4. If binaries are to be used instead of lists
      of bytes, the option <span class="code">binary</span> must be included.</p>
    <p>The port owner <span class="code">Pid</span> can communicate with the port
      <span class="code">Port</span> by sending and receiving messages. (In fact, any
      process can send the messages to the port, but the port owner must
      be identified in the message).</p>
    <p>As of Erlang/OTP R16, messages sent to ports are delivered truly
      asynchronously. The underlying implementation previously
      delivered messages to ports synchronously. Message passing has
      however always been documented as an asynchronous operation. Hence,
      this is not to be an issue for an Erlang program communicating
      with ports, unless false assumptions about ports have been made.</p>
    <p>In the following tables of examples, <span class="code">Data</span> must be an I/O list.
      An I/O list is a binary or a (possibly deep) list of binaries
      or integers in the range 0..255:</p>
    <div class="doc-table-wrapper">
<table class="doc-table">
<tr>
        <td align="left" valign="middle"><strong>Message</strong></td>
        <td align="left" valign="middle"><strong>Description</strong></td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{Pid,{command,Data}}</span></td>
        <td align="left" valign="middle">Sends <span class="code">Data</span> to the port.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{Pid,close}</span></td>
        <td align="left" valign="middle">Closes the port. Unless the
        port is already closed, the port replies with
        <span class="code">{Port,closed}</span> when all buffers have been flushed
        and the port really closes.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{Pid,{connect,NewPid}}</span></td>
        <td align="left" valign="middle">Sets the port owner of
        <span class="code">Port</span>to <span class="code">NewPid</span>. Unless the port is already closed,
        the port replies with<span class="code">{Port,connected}</span> to the old
        port owner. Note that the old port owner is still linked
        to the port, but the new port owner is not.</td>
      </tr>
</table>
<p class="doc-table-caption">Table
        15.2:
         
        Messages Sent To a Port</p>
</div>
    <p></p>
    <div class="doc-table-wrapper">
<table class="doc-table">
<tr>
        <td align="left" valign="middle"><strong>Message</strong></td>
        <td align="left" valign="middle"><strong>Description</strong></td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{Port,{data,Data}}</span></td>
        <td align="left" valign="middle">
<span class="code">Data</span> is received from the external program.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{Port,closed}</span></td>
        <td align="left" valign="middle">Reply to <span class="code">Port ! {Pid,close}</span>.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{Port,connected}</span></td>
        <td align="left" valign="middle">Reply to <span class="code">Port ! {Pid,{connect,NewPid}}</span>.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">{'EXIT',Port,Reason}</span></td>
        <td align="left" valign="middle">If the port has terminated for some reason.</td>
      </tr>
</table>
<p class="doc-table-caption">Table
        15.3:
         
        Messages Received From a Port</p>
</div>
    <p>Instead of sending and receiving messages, there are also a
      number of BIFs that can be used:</p>
    <div class="doc-table-wrapper">
<table class="doc-table">
<tr>
        <td align="left" valign="middle"><strong>Port BIF</strong></td>
        <td align="left" valign="middle"><strong>Description</strong></td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">port_command(Port,Data)</span></td>
        <td align="left" valign="middle">Sends <span class="code">Data</span> to the port.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">port_close(Port)</span></td>
        <td align="left" valign="middle">Closes the port.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">port_connect(Port,NewPid)</span></td>
        <td align="left" valign="middle">Sets the port owner of
        <span class="code">Port</span>to <span class="code">NewPid</span>. The old port owner <span class="code">Pid</span>
        stays linked to the port and must call <span class="code">unlink(Port)</span>
        if this is not desired.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">erlang:port_info(Port,Item)</span></td>
        <td align="left" valign="middle">Returns information as specified by <span class="code">Item</span>.</td>
      </tr>
<tr>
        <td align="left" valign="middle"><span class="code">erlang:ports()</span></td>
        <td align="left" valign="middle">Returns a list of all ports on the current node.</td>
      </tr>
</table>
<p class="doc-table-caption">Table
        15.4:
         
        Port BIFs</p>
</div>
    <p>Some additional BIFs that apply to port drivers:
      <span class="code">port_control/3</span> and <span class="code">erlang:port_call/3</span>.</p>
  
</div>
<div class="footer">
<hr>
<p>Copyright © 2003-2019 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div>
<script type="text/javascript">window.__otpTopDocDir = '../js/';</script><script type="text/javascript" src="../js/highlight.js"></script>
</body>
</html>