logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

getpeername.3p (3297B)


  1. '\" et
  2. .TH GETPEERNAME "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. getpeername
  12. \(em get the name of the peer socket
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/socket.h>
  17. .P
  18. int getpeername(int \fIsocket\fP, struct sockaddr *restrict \fIaddress\fP,
  19. socklen_t *restrict \fIaddress_len\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The
  23. \fIgetpeername\fR()
  24. function shall retrieve the peer address of the specified socket,
  25. store this address in the
  26. .BR sockaddr
  27. structure pointed to by the
  28. .IR address
  29. argument, and store the length of this address in the object pointed
  30. to by the
  31. .IR address_len
  32. argument.
  33. .P
  34. The
  35. .IR address_len
  36. argument points to a
  37. .BR socklen_t
  38. object which on input specifies the length of the supplied
  39. .BR sockaddr
  40. structure, and on output specifies the length of the stored address.
  41. If the actual length of the address is greater than the length of the
  42. supplied
  43. .BR sockaddr
  44. structure, the stored address shall be truncated.
  45. .P
  46. If the protocol permits connections by unbound clients, and the peer is
  47. not bound, then the value stored in the object pointed to by
  48. .IR address
  49. is unspecified.
  50. .SH "RETURN VALUE"
  51. Upon successful completion, 0 shall be returned. Otherwise, \-1 shall
  52. be returned and
  53. .IR errno
  54. set to indicate the error.
  55. .SH ERRORS
  56. The
  57. \fIgetpeername\fR()
  58. function shall fail if:
  59. .TP
  60. .BR EBADF
  61. The
  62. .IR socket
  63. argument is not a valid file descriptor.
  64. .TP
  65. .BR EINVAL
  66. The socket has been shut down.
  67. .TP
  68. .BR ENOTCONN
  69. The socket is not connected or otherwise has not had the peer
  70. pre-specified.
  71. .TP
  72. .BR ENOTSOCK
  73. The
  74. .IR socket
  75. argument does not refer to a socket.
  76. .TP
  77. .BR EOPNOTSUPP
  78. The operation is not supported for the socket protocol.
  79. .P
  80. The
  81. \fIgetpeername\fR()
  82. function may fail if:
  83. .TP
  84. .BR ENOBUFS
  85. Insufficient resources were available in the system to complete the
  86. call.
  87. .LP
  88. .IR "The following sections are informative."
  89. .SH "EXAMPLES"
  90. None.
  91. .SH "APPLICATION USAGE"
  92. None.
  93. .SH "RATIONALE"
  94. None.
  95. .SH "FUTURE DIRECTIONS"
  96. None.
  97. .SH "SEE ALSO"
  98. .IR "\fIaccept\fR\^(\|)",
  99. .IR "\fIbind\fR\^(\|)",
  100. .IR "\fIgetsockname\fR\^(\|)",
  101. .IR "\fIsocket\fR\^(\|)"
  102. .P
  103. The Base Definitions volume of POSIX.1\(hy2017,
  104. .IR "\fB<sys_socket.h>\fP"
  105. .br
  106. .\"
  107. .SH COPYRIGHT
  108. Portions of this text are reprinted and reproduced in electronic form
  109. from IEEE Std 1003.1-2017, Standard for Information Technology
  110. -- Portable Operating System Interface (POSIX), The Open Group Base
  111. Specifications Issue 7, 2018 Edition,
  112. Copyright (C) 2018 by the Institute of
  113. Electrical and Electronics Engineers, Inc and The Open Group.
  114. In the event of any discrepancy between this version and the original IEEE and
  115. The Open Group Standard, the original IEEE and The Open Group Standard
  116. is the referee document. The original Standard can be obtained online at
  117. http://www.opengroup.org/unix/online.html .
  118. .PP
  119. Any typographical or formatting errors that appear
  120. in this page are most likely
  121. to have been introduced during the conversion of the source files to
  122. man page format. To report such errors, see
  123. https://www.kernel.org/doc/man-pages/reporting_bugs.html .