Commit | Line | Data |
---|---|---|
931b8415 | 1 | .\" Copyright (c) 1983, 1991 The Regents of the University of California. |
da268306 | 2 | .\" All rights reserved. |
c93f2ba8 | 3 | .\" |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
da268306 | 5 | .\" |
931b8415 | 6 | .\" @(#)getpeername.2 6.5 (Berkeley) %G% |
c93f2ba8 | 7 | .\" |
931b8415 CL |
8 | .Dd |
9 | .Dt GETPEERNAME 2 | |
10 | .Os BSD 4.2 | |
11 | .Sh NAME | |
12 | .Nm getpeername | |
13 | .Nd get name of connected peer | |
14 | .Sh SYNOPSIS | |
15 | .Ft int | |
16 | .Fn getpeername "int s" "struct sockaddr *name" "int *namelen" | |
17 | .Sh DESCRIPTION | |
18 | .Fn Getpeername | |
c93f2ba8 KM |
19 | returns the name of the peer connected to |
20 | socket | |
931b8415 | 21 | .Fa s . |
c93f2ba8 | 22 | The |
931b8415 | 23 | .Fa namelen |
c93f2ba8 KM |
24 | parameter should be initialized to indicate |
25 | the amount of space pointed to by | |
931b8415 | 26 | .Fa name . |
c93f2ba8 KM |
27 | On return it contains the actual size of the name |
28 | returned (in bytes). | |
e4589241 | 29 | The name is truncated if the buffer provided is too small. |
931b8415 CL |
30 | .Sh DIAGNOSTICS |
31 | A 0 is returned if the call succeeds, -1 if it fails. | |
32 | .Sh ERRORS | |
c93f2ba8 | 33 | The call succeeds unless: |
931b8415 CL |
34 | .Bl -tag -width ENOTSOCKAA |
35 | .It Bq Er EBADF | |
36 | The argument | |
37 | .Fa s | |
38 | is not a valid descriptor. | |
39 | .It Bq Er ENOTSOCK | |
40 | The argument | |
41 | .Fa s | |
42 | is a file, not a socket. | |
43 | .It Bq Er ENOTCONN | |
c93f2ba8 | 44 | The socket is not connected. |
931b8415 | 45 | .It Bq Er ENOBUFS |
c93f2ba8 KM |
46 | Insufficient resources were available in the system |
47 | to perform the operation. | |
931b8415 | 48 | .It Bq Er EFAULT |
c93f2ba8 | 49 | The |
931b8415 | 50 | .Fa name |
c93f2ba8 KM |
51 | parameter points to memory not in a valid part of the |
52 | process address space. | |
931b8415 CL |
53 | .El |
54 | .Sh SEE ALSO | |
55 | .Xr accept 2 , | |
56 | .Xr bind 2 , | |
57 | .Xr socket 2 , | |
58 | .Xr getsockname 2 | |
59 | .Sh HISTORY | |
60 | The | |
61 | .Nm | |
62 | function call appeared in | |
63 | .Bx 4.2 . |