next up previous index
Next: Pseudo-Terminals (PTYs) Up: Chapter 6: Interprocess Communication Previous: Messages   Index

Ports

GNO/ME Ports IPC can be thought of as an extended version of Messages. Whereas only one message can be pending at once, a port can contain any number of pending messages (up to a limit defined when an application creates a port).

Like Messages, Ports transmit 32-bit values between processes. The calls psend(2) and preceive(2) work similarly to their Message counterparts.

A Port is created with the pcreate(2) call. The application specifies the size of the port in this call. When the application is done with the port, it should call pdelete(2) to free up the resources used by the port.

One of the most important aspects of ports is the ability to bind a name to a port. Whereas many of GNO/ME IPC mechanisms require the communicating processes to be related in some way (common children of the same parent, for instance) being able to give a port a name means that totally unrelated processes can communicate. For example, the GNO/ME print spooling system uses a named port for communicating information about the addition of new jobs to the print queue. The printer daemon, lpd(8), creates a port with a specific name; the name is defined by the author of the print daemon; any application that wishes to have the daemon print a spool file also knows this name. (The standard print daemon uses the name ``LPDPrinter''). The name allows an application to find lpd's port regardless of the actual numeric port ID (which might be different from system to system, or even from session to session on the same machine).

Names are bound to ports with the pbind(2) call. The numeric port ID can be obtained by passing a name to pgetport(2).


next up previous index
Next: Pseudo-Terminals (PTYs) Up: Chapter 6: Interprocess Communication Previous: Messages   Index
Feedback