| <html lang="en"> |
| <head> |
| <title>Communication Styles - The GNU C Library</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="The GNU C Library"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Sockets.html#Sockets" title="Sockets"> |
| <link rel="prev" href="Socket-Concepts.html#Socket-Concepts" title="Socket Concepts"> |
| <link rel="next" href="Socket-Addresses.html#Socket-Addresses" title="Socket Addresses"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| This file documents the GNU C library. |
| |
| This is Edition 0.12, last updated 2007-10-27, |
| of `The GNU C Library Reference Manual', for version |
| 2.8 (Sourcery G++ Lite 2011.03-41). |
| |
| Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, |
| 2003, 2007, 2008, 2010 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Free Software Needs Free Documentation'' |
| and ``GNU Lesser General Public License'', the Front-Cover texts being |
| ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A |
| copy of the license is included in the section entitled "GNU Free |
| Documentation License". |
| |
| (a) The FSF's Back-Cover Text is: ``You have the freedom to |
| copy and modify this GNU manual. Buying copies from the FSF |
| supports it in developing GNU and promoting software freedom.''--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| <link rel="stylesheet" type="text/css" href="../cs.css"> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Communication-Styles"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Socket-Addresses.html#Socket-Addresses">Socket Addresses</a>, |
| Previous: <a rel="previous" accesskey="p" href="Socket-Concepts.html#Socket-Concepts">Socket Concepts</a>, |
| Up: <a rel="up" accesskey="u" href="Sockets.html#Sockets">Sockets</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">16.2 Communication Styles</h3> |
| |
| <p>The GNU library includes support for several different kinds of sockets, |
| each with different characteristics. This section describes the |
| supported socket types. The symbolic constants listed here are |
| defined in <samp><span class="file">sys/socket.h</span></samp>. |
| <a name="index-sys_002fsocket_002eh-1647"></a> |
| <!-- sys/socket.h --> |
| <!-- BSD --> |
| |
| <div class="defun"> |
| — Macro: int <b>SOCK_STREAM</b><var><a name="index-SOCK_005fSTREAM-1648"></a></var><br> |
| <blockquote><p>The <code>SOCK_STREAM</code> style is like a pipe (see <a href="Pipes-and-FIFOs.html#Pipes-and-FIFOs">Pipes and FIFOs</a>). |
| It operates over a connection with a particular remote socket and |
| transmits data reliably as a stream of bytes. |
| |
| <p>Use of this style is covered in detail in <a href="Connections.html#Connections">Connections</a>. |
| </p></blockquote></div> |
| |
| <!-- sys/socket.h --> |
| <!-- BSD --> |
| <div class="defun"> |
| — Macro: int <b>SOCK_DGRAM</b><var><a name="index-SOCK_005fDGRAM-1649"></a></var><br> |
| <blockquote><p>The <code>SOCK_DGRAM</code> style is used for sending |
| individually-addressed packets unreliably. |
| It is the diametrical opposite of <code>SOCK_STREAM</code>. |
| |
| <p>Each time you write data to a socket of this kind, that data becomes |
| one packet. Since <code>SOCK_DGRAM</code> sockets do not have connections, |
| you must specify the recipient address with each packet. |
| |
| <p>The only guarantee that the system makes about your requests to |
| transmit data is that it will try its best to deliver each packet you |
| send. It may succeed with the sixth packet after failing with the |
| fourth and fifth packets; the seventh packet may arrive before the |
| sixth, and may arrive a second time after the sixth. |
| |
| <p>The typical use for <code>SOCK_DGRAM</code> is in situations where it is |
| acceptable to simply re-send a packet if no response is seen in a |
| reasonable amount of time. |
| |
| <p>See <a href="Datagrams.html#Datagrams">Datagrams</a>, for detailed information about how to use datagram |
| sockets. |
| </p></blockquote></div> |
| |
| <!-- sys/socket.h --> |
| <!-- BSD --> |
| <div class="defun"> |
| — Macro: int <b>SOCK_RAW</b><var><a name="index-SOCK_005fRAW-1650"></a></var><br> |
| <blockquote><p>This style provides access to low-level network protocols and |
| interfaces. Ordinary user programs usually have no need to use this |
| style. |
| </p></blockquote></div> |
| |
| </body></html> |
| |