You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ram_file_drv`, `binary_filer`, `tty_sl`. These drivers are used to
301
-
implement e.g. file handling and sockets in Erlang. On Windows there
301
+
implement, e.g., file handling and sockets in Erlang. On Windows there
302
302
is also a driver to access the registry: `registry_drv`. And on most
303
303
platforms there are example drivers to use when implementing your own
304
304
driver like: `multi_drv` and `sig_drv`.
@@ -322,7 +322,7 @@ Data sent to and from a port are byte streams. The packet size can be specified
322
322
323
323
Ports can be used to replace standard IO and polling. This is useful when you need to interact with external programs or devices. By opening a port to a file descriptor, you can read and write data to the file. Similarly, you can open a port to an external program and communicate with it using the port interface.
324
324
325
-
===== Ports to file descriptors =====
325
+
===== Ports to File Descriptors =====
326
326
327
327
File descriptor ports in Erlang provide an interface to interact with already opened file descriptors. Although they are not commonly used due to efficiency concerns, they can provide an easy interface to external resources.
328
328
@@ -352,10 +352,9 @@ The primary commands for interacting with a port include:
352
352
* `{control, Operation, Data}`: Sends a control command to the external program.
353
353
* `{exit_status, Status}`: Receives the exit status of the external program.
354
354
355
-
See xref:CH-C[] for examples of how to spawn an external program as a port,
356
-
you can also look at the official documentation: link:https://www.erlang.org/doc/system/c_port.html#content[erlang.org:c_port].
355
+
See xref:CH-C[] for examples of how to spawn an external program as a port. You can also look at the official documentation: link:https://www.erlang.org/doc/system/c_port.html#content[erlang.org:c_port].
357
356
358
-
===== Ports to Linkedin Drivers =====
357
+
===== Ports to Linked-in Drivers =====
359
358
360
359
Linked-in drivers in Erlang are created using the `open_port/2` function with the `{spawn_driver, Command}` tuple as the `PortName`. This method requires the first token of the command to be the name of a loaded driver.
361
360
@@ -373,7 +372,7 @@ Example:
373
372
Port ! {self(), {command, <<"Hello, Driver!\n">>}}.
374
373
```
375
374
376
-
See xref:CH-C[] for examples of how to implement and spawn a linked in driver as a port, you can also look at the official documentation: link:https://www.erlang.org/doc/system/c_portdriver.html#content[erlang.org:c_portdriver].
375
+
See xref:CH-C[] for examples of how to implement and spawn a linked in driver as a port. You can also look at the official documentation: link:https://www.erlang.org/doc/system/c_portdriver.html#content[erlang.org:c_portdriver].
377
376
378
377
==== Flow Control in Erlang Ports
379
378
@@ -532,7 +531,7 @@ distribution layer.
532
531
=== Sockets, UDP and TCP ===
533
532
Sockets are a fundamental aspect of network communication in Erlang. They allow processes to communicate over a network using protocols such as TCP and UDP. Here, we will explore how to work with sockets, retrieve information about sockets, and tweak socket behavior.
534
533
535
-
Erlang provides a robust set of functions for creating and managing sockets. The gen_tcp and gen_udp modules facilitate the use of TCP and UDP protocols, respectively. Here is a basic example of opening a TCP socket:
534
+
Erlang provides a robust set of functions for creating and managing sockets. The `gen_tcp` and `gen_udp` modules facilitate the use of TCP and UDP protocols, respectively. Here is a basic example of opening a TCP socket:
536
535
537
536
```erlang
538
537
% Open a listening socket on port 1234
@@ -546,7 +545,7 @@ ok = gen_tcp:send(Socket, <<"Hello, World!">>),
546
545
{ok, Data} = gen_tcp:recv(Socket, 0).
547
546
```
548
547
549
-
For UDP, the process is similar but uses the 'gen_udp' module:
548
+
For UDP, the process is similar but uses the `gen_udp` module:
550
549
551
550
```erlang
552
551
% Open a UDP socket on port 1234
@@ -570,7 +569,7 @@ Erlang provides several functions to retrieve information about sockets. For ins
570
569
% Set options on a socket
571
570
ok = inet:setopts(Socket, [{recbuf, 4096}, {sndbuf, 4096}, {nodelay, true}]).
572
571
```
573
-
Additionally, you can use inet:peername/1 and inet:sockname/1 to get the remote and local addresses of a socket:
572
+
Additionally, you can use `inet:peername/1` and `inet:sockname/1` to get the remote and local addresses of a socket:
0 commit comments