getpeername man page on IRIX

Man page or keyword search:  
man Server   31559 pages
apropos Keyword Search (all sections)
Output format
IRIX logo
[printable version]



GETPEERNAME(2)							GETPEERNAME(2)

NAME
     getpeername - get name of connected peer

SYNOPSIS
     #include <sys/types.h>
     #include <sys/socket.h>

     int getpeername (int s, struct sockaddr *name, socklen_t *namelen);

     #if _XOPEN_SOURCE >= 500
       int getpeername (int s, struct sockaddr *name, socklen_t *namelen);
     #elif _XOPEN_SOURCE < 500
       int getpeername (int s, struct sockaddr *name, size_t *namelen);
     #endif

DESCRIPTION
     Getpeername returns the name of the peer connected to socket s.  The
     namelen parameter should be initialized to indicate the amount of space
     pointed to by name.  On return it contains the actual size of the name
     returned (in bytes).  The name is truncated if the buffer provided is too
     small.

DIAGNOSTICS
     A 0 is returned if the call succeeds, -1 if it fails.

ERRORS
     The call succeeds unless:

     [EBADF]	    The argument s is not a valid descriptor.

     [ENOTSOCK]	    The argument s is a file, not a socket.

     [ENOTCONN]	    The socket is not connected.

     [ENOBUFS]	    Insufficient resources were available in the system to
		    perform the operation.

     [EFAULT]	    The name parameter points to memory not in a valid part of
		    the process address space.

SEE ALSO
     accept(2), bind(2), socket(2), getsockname(2)

NOTES
     ABI-compliant versions of the above call can be obtained from
     libsocket.so.

     This call does not return useful results when used on sockets of type
     AF_UNIX, unless the remote end was explicitly bound to a pathname.

									Page 1

GETPEERNAME(2)							GETPEERNAME(2)

     There are three types of getpeername functions in n32 and 64 bit C
     libraries for IRIX 6.5.19 and later versions. One is the normal type when
     _XOPEN_SOURCE is not defined; the second is XPG5 type when _XOPEN_SOURCE
     is set to >= 500; and the third is XPG4 type when _XOPEN_SOURCE set to <
     500.  The difference between these functions is in the third argument
     type to getpeername.  Refer <sys/socket.h> for alternate definitions of
     socklen_t type.

     1. For the normal case when _XOPEN_SOURCE is not defined, third argument
     type, a pointer to a socklen_t type, will actually be a pointer to an int
     and the normal getpeername is used.
     2. When _XOPEN_SOURCE is set to >= 500, third argument type, a pointer to
     a socklen_t type, will actually be a pointer to u_int32_t type and xpg5
     type function will be used.
     3. When _XOPEN_SOURCE is set to < 500, third argument type will be a
     pointer to a size_t type and xpg4 type function will be used.

     XPG5 type function is not supported in o32 C library.
     The XPG5 type getpeername function is actually defined as a static inline
     function in <sys/socket.h>, and it calls a new function _xpg5_getpeername
     which is specific to IRIX 6.5.19 and later. Therefore applications that
     call XPG5 type getpeername should check the existence of the new symbol.

	    #include <sys/socket.h>
	    #include <optional_sym.h>

	    if (_MIPS_SYMBOL_PRESENT(_xpg5_getpeername)) {
		  getpeername(s, &addr, &addrlen);
	    } else {
		  ...
	    }

     Because the static inline function is defined in each source file that
     includes <sys/socket.h>, these static functions will have different
     addresses in any cases that inline expansion is not performed. This may
     cause problems if the address of the function is examined in programs.
     To avoid this problem, use -D_XPG5_GETPEERNAME_USER_DEFINED compile
     option to disable the static inline definition in <sys/socket.h>, and
     define a user defined function with below definition:

	  int *
	  getpeername(int _s, struct sockaddr *_name, socklen_t *_namelen)
	  {
	      return(_xpg5_getpeername(_s, _name, _namelen));
	  }

     Use the compile option always, when a user defined XPG5 getpeername
     function is required.

									Page 2

[top]

List of man pages available for IRIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net