PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

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