PageRenderTime 125ms CodeModel.GetById 116ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/share/doc/arm-arm-none-linux-gnueabi/html/libc/Socket-Addresses.html

https://github.com/apc-io/apc-rock-toolchain
HTML | 101 lines | 60 code | 10 blank | 31 comment | 0 complexity | 8ae3a217e0287ae17118f3f20609cac0 MD5 | raw file
  1<html lang="en">
  2<head>
  3<title>Socket Addresses - The GNU C Library</title>
  4<meta http-equiv="Content-Type" content="text/html">
  5<meta name="description" content="The GNU C Library">
  6<meta name="generator" content="makeinfo 4.13">
  7<link title="Top" rel="start" href="index.html#Top">
  8<link rel="up" href="Sockets.html#Sockets" title="Sockets">
  9<link rel="prev" href="Communication-Styles.html#Communication-Styles" title="Communication Styles">
 10<link rel="next" href="Interface-Naming.html#Interface-Naming" title="Interface Naming">
 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
 12<!--
 13This file documents the GNU C library.
 14
 15This is Edition 0.12, last updated 2007-10-27,
 16of `The GNU C Library Reference Manual', for version
 172.8 (Sourcery G++ Lite 2011.03-41).
 18
 19Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
 202003, 2007, 2008, 2010 Free Software Foundation, Inc.
 21
 22Permission is granted to copy, distribute and/or modify this document
 23under the terms of the GNU Free Documentation License, Version 1.3 or
 24any later version published by the Free Software Foundation; with the
 25Invariant Sections being ``Free Software Needs Free Documentation''
 26and ``GNU Lesser General Public License'', the Front-Cover texts being
 27``A GNU Manual'', and with the Back-Cover Texts as in (a) below.  A
 28copy of the license is included in the section entitled "GNU Free
 29Documentation License".
 30
 31(a) The FSF's Back-Cover Text is: ``You have the freedom to
 32copy and modify this GNU manual.  Buying copies from the FSF
 33supports it in developing GNU and promoting software freedom.''-->
 34<meta http-equiv="Content-Style-Type" content="text/css">
 35<style type="text/css"><!--
 36  pre.display { font-family:inherit }
 37  pre.format  { font-family:inherit }
 38  pre.smalldisplay { font-family:inherit; font-size:smaller }
 39  pre.smallformat  { font-family:inherit; font-size:smaller }
 40  pre.smallexample { font-size:smaller }
 41  pre.smalllisp    { font-size:smaller }
 42  span.sc    { font-variant:small-caps }
 43  span.roman { font-family:serif; font-weight:normal; } 
 44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
 45--></style>
 46<link rel="stylesheet" type="text/css" href="../cs.css">
 47</head>
 48<body>
 49<div class="node">
 50<a name="Socket-Addresses"></a>
 51<p>
 52Next:&nbsp;<a rel="next" accesskey="n" href="Interface-Naming.html#Interface-Naming">Interface Naming</a>,
 53Previous:&nbsp;<a rel="previous" accesskey="p" href="Communication-Styles.html#Communication-Styles">Communication Styles</a>,
 54Up:&nbsp;<a rel="up" accesskey="u" href="Sockets.html#Sockets">Sockets</a>
 55<hr>
 56</div>
 57
 58<h3 class="section">16.3 Socket Addresses</h3>
 59
 60<p><a name="index-address-of-socket-1651"></a><a name="index-name-of-socket-1652"></a><a name="index-binding-a-socket-address-1653"></a><a name="index-socket-address-_0028name_0029-binding-1654"></a>The name of a socket is normally called an <dfn>address</dfn>.  The
 61functions and symbols for dealing with socket addresses were named
 62inconsistently, sometimes using the term &ldquo;name&rdquo; and sometimes using
 63&ldquo;address&rdquo;.  You can regard these terms as synonymous where sockets
 64are concerned.
 65
 66   <p>A socket newly created with the <code>socket</code> function has no
 67address.  Other processes can find it for communication only if you
 68give it an address.  We call this <dfn>binding</dfn> the address to the
 69socket, and the way to do it is with the <code>bind</code> function.
 70
 71   <p>You need be concerned with the address of a socket if other processes
 72are to find it and start communicating with it.  You can specify an
 73address for other sockets, but this is usually pointless; the first time
 74you send data from a socket, or use it to initiate a connection, the
 75system assigns an address automatically if you have not specified one.
 76
 77   <p>Occasionally a client needs to specify an address because the server
 78discriminates based on address; for example, the rsh and rlogin
 79protocols look at the client's socket address and only bypass password
 80checking if it is less than <code>IPPORT_RESERVED</code> (see <a href="Ports.html#Ports">Ports</a>).
 81
 82   <p>The details of socket addresses vary depending on what namespace you are
 83using.  See <a href="Local-Namespace.html#Local-Namespace">Local Namespace</a>, or <a href="Internet-Namespace.html#Internet-Namespace">Internet Namespace</a>, for specific
 84information.
 85
 86   <p>Regardless of the namespace, you use the same functions <code>bind</code> and
 87<code>getsockname</code> to set and examine a socket's address.  These
 88functions use a phony data type, <code>struct sockaddr *</code>, to accept the
 89address.  In practice, the address lives in a structure of some other
 90data type appropriate to the address format you are using, but you cast
 91its address to <code>struct sockaddr *</code> when you pass it to
 92<code>bind</code>.
 93
 94<ul class="menu">
 95<li><a accesskey="1" href="Address-Formats.html#Address-Formats">Address Formats</a>: 		About <code>struct sockaddr</code>. 
 96<li><a accesskey="2" href="Setting-Address.html#Setting-Address">Setting Address</a>: 		Binding an address to a socket. 
 97<li><a accesskey="3" href="Reading-Address.html#Reading-Address">Reading Address</a>: 		Reading the address of a socket. 
 98</ul>
 99
100   </body></html>
101