*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> recv (2)              



NAME    [Toc]    [Back]

       recv - Receive messages from connected sockets

SYNOPSIS    [Toc]    [Back]

       #include <sys/socket.h>

       ssize_t recv(
               int socket,
               void *buffer,
               size_t length,
               int options );

       [Tru64 UNIX]  The following definition of the recv() function
 does not conform to current  standards  and  is  supported
 only for backward compatibility (see standards(5)):
       #include <sys/socket.h>

       int recv(
               int socket,
               char *buffer,
               int length,
               int options );

STANDARDS    [Toc]    [Back]

       Interfaces documented on this reference  page  conform  to
       industry standards as follows:

       recv(): XNS4.0, XNS5.0

       Refer to the standards(5) reference page for more information
 about industry standards and associated tags.

PARAMETERS    [Toc]    [Back]

       Specifies the socket descriptor.  Points to a buffer where
       the  message  should be placed.  Specifies the size of the
       buffer pointed to by the buffer parameter.   Points  to  a
       value  controlling  the  message  reception.  The  options
       parameter is formed by logically ORing one or more of  the
       following  values,  defined in the sys/socket.h file: Peek
       at incoming message. The data is treated as unread and the
       next  recv()  function  (or  similar  function) will still
       return this data.   Process  out-of-band  data.   Requests
       that the function block wait until the full amount of data
       requested can be  returned.  The  function  may  return  a
       smaller  amount of data if a signal is caught, the connection
 is terminated, or an error is pending for the socket.

DESCRIPTION    [Toc]    [Back]

       The  recv()  function  receives  messages from a connected
       socket. The recvfrom()  and  recvmsg()  functions  receive
       messages from both connected and unconnected sockets; however,
 they are usually used for unconnected sockets  only.

       The recv() function returns the length of the message.  If
       a message is too long  to  fit  in  the  supplied  buffer,
       excess  bytes  may  be  truncated depending on the type of
       socket that issued the message.

       If no messages are available at  the  socket,  the  recv()
       function  waits for a message to arrive, unless the socket
       is nonblocking.  If a socket is nonblocking, errno is  set
       to [EWOULDBLOCK].

       Use  the  select()  function  to  determine when more data

NOTES    [Toc]    [Back]

       [Tru64 UNIX]  The recv()  function  is  identical  to  the
       recvfrom() function with a zero-valued address_len parameter,
 and to the read() function if no  options  are  used.
       For  that  reason  the  recv()  function  is disabled when
       4.4BSD behavior is  enabled;  that  is,  when  the  _SOCKADDR_LEN
 compile-time option is defined.

RETURN VALUES    [Toc]    [Back]

       Upon  successful  completion,  the recv() function returns
       the length of the message in bytes.  If  no  messages  are
       available  and  the  peer  has  closed the connection, the
       recv() function returns a value of 0. Otherwise, the function
  returns a value of -1 and sets errno to indicate the

ERRORS    [Toc]    [Back]

       If the recv() function fails, errno may be set to  one  of
       the  following values: The read() would cause the information
 label of the process to float to an information level
       that  is not dominated by the process's sensitivity level.
       The socket parameter  is  not  valid.   A  connection  was
       forcibly  closed  by  a peer.  The data was directed to be
       received into a nonexistent or protected part of the  process
  address  space.  The buffer parameter is invalid.  A
       signal interrupted the recv() function before any data was
       available.   The  MSG_OOB option is set and no out-of-band
       data is available.  An I/O error  occurred  while  reading
       from   or   writing  to  the  file  system.   Insufficient
       resources were available in the  system  to  complete  the
       call.   The  system did not have sufficient memory to fulfill
 the request.  The available  STREAMS  resources  were
       insufficient  for  the  operation to complete.  Receive is
       attempted on a connection-oriented socket that is not connected.
   The  socket  parameter  refers  to a file, not a
       socket.  The specified options are not supported for  this
       socket  type or protocol.  The connection timed out during
       connection establishment or due to a transmission  timeout
       on  active  connection.  The socket is marked nonblocking,
       and no data is waiting to be received.

SEE ALSO    [Toc]    [Back]

       Functions: recvfrom(2), recvmsg(2),  send(2),  sendmsg(2),
       sendto(2),  select(2),  shutdown(2),  socket(2),  read(2),

       Standards: standards(5)

       Network Programmer's Guide

[ Back ]
 Similar pages
Name OS Title
recvfrom Tru64 Receive messages from sockets
socketpair NetBSD create a pair of connected sockets
socketpair IRIX create a pair of connected sockets
socketpair IRIX create a pair of connected sockets
socketpair HP-UX create a pair of connected sockets
socketpair Linux create a pair of connected sockets
socketpair OpenBSD create a pair of connected sockets
socketpair Tru64 Create a pair of connected sockets
socketpair FreeBSD create a pair of connected sockets
writesrv Tru64 Lets users send messages to and receive messages from a remote system
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service