MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Sockets Library Functions                           send(3SOCKET)



NAME
     send, sendto, sendmsg - send a message from a socket

SYNOPSIS
     cc [ flag... ] file... -lsocket  -lnsl  [ library... ]
     #include 
     #include 

     ssizet send(int s, const void *msg, sizet len, int flags);


     ssizet sendto(int s, const void *msg, sizet len, int flags,
          const struct sockaddr *to, int  tolen);


     ssizet sendmsg(int s, const struct msghdr *msg, int flags);


DESCRIPTION
     The send(), sendto(), and sendmsg() functions  are  used  to
     transmit  a  message  to  another  transport  end-point. The
     send() function can be used only when the  socket  is  in  a
     connected  state.  See  connect(3SOCKET).  The  sendto() and
     sendmsg() functions can be used at any time. The s socket is
     created with socket(3SOCKET).


     The address of the target is supplied by  to  with  a  tolen
     parameter  used  to specify the size. The length of the mes-
     sage is supplied by the len parameter. For socket types such
     as SOCKDGRAM and SOCKRAW that require atomic messages, the
     error EMSGSIZE is returned and the message is not  transmit-
     ted  when  it  is  too  long  to pass atomically through the
     underlying protocol. The same restrictions do not  apply  to
     SOCKSTREAM sockets.


     A return value -1 indicates locally detected errors. It does
     not imply a delivery failure.


     If the socket does not have enough buffer space available to
     hold  a  message,  the  send()  function blocks the message,
     unless the socket has been placed in non-blocking  I/O  mode
     (see  fcntl(2)).  The select(3C) or poll(2) call can be used
     to determine when it is possible to send more data.


     The flags parameter is formed from the bitwise OR of zero or
     more of the following:





SunOS 5.11          Last change: 16 Jul 2004                    1






Sockets Library Functions                           send(3SOCKET)



     MSGOB          Send out-of-band data on sockets that  sup-
                      port  this  notion. The underlying protocol
                      must also support  out-of-band  data.  Only
                      SOCKSTREAM  sockets created in the AFINET
                      or  the  AFINET6  address  family  support
                      out-of-band data.


     MSGDONTROUTE    The SODONTROUTE option is  turned  on  for
                      the  duration  of the operation. It is used
                      only by diagnostic or routing programs.



     See recv(3SOCKET) for a description of the msghdr structure.

RETURN VALUES
     Upon  successful  completion,  these  functions  return  the
     number  of  bytes  sent.  Otherwise,  they return -1 and set
     errno to indicate the error.

ERORS
     The send(), sendto(), and sendmsg() functions return  errors
     under the following conditions:

     EBADF           s is not a valid file descriptor.


     EINTR           The operation was interrupted by delivery of
                     a  signal  before any data could be buffered
                     to be sent.


     EMSGSIZE        The socket requires that the message be sent
                     atomically and the message is too long.


     ENOMEM          Insufficient memory is available to complete
                     the operation.


     ENOSR           Insufficient STREAMS resources are available
                     for the operation to complete.


     ENOTSOCK        s is not a socket.


     EWOULDBLOCK     The socket is marked  non-blocking  and  the
                     requested operation would block. EWOULDBLOCK
                     is also returned when sufficient  memory  is
                     not  immediately  available  to  allocate  a



SunOS 5.11          Last change: 16 Jul 2004                    2






Sockets Library Functions                           send(3SOCKET)



                     suitable buffer. In such a case, the  opera-
                     tion can be retried later.


     ECONREFUSED    The requested connection was refused by  the
                     peer.  For  conected  IPv4 and IPv6 datagram
                     sockets,  this  indicates  that  the  system
                     received  an  ICMP Destination Port Unreach-
                     able message from the peer  in  response  to
                     some prior transmission.



     The send() and sendto() functions return  errors  under  the
     following conditions:

     EINVAL    The len argument overflows a ssizet.



     The sendto() function returns  errors  under  the  following
     conditions:

     EINVAL    The value specified for the tolen parameter is not
               the  size  of  a  valid  address for the specified
               address family.


     EISCON    A destination address was specified and the socket
               is already connected.



     The sendmsg() function returns errors  under  the  following
     conditions:

     EINVAL    The msgiovlen  member  of  the  msghdr  structure
               pointed  to  by msg is less than or equal to 0, or
               the sum of the iovlen values in the msgiov array
               overflows a ssizet.


     EINVAL    One of the iovlen values  in  the  msgiov  array
               member  of  the msghdr structure pointed to by msg
               is negative, or the sum of the iovlen  values  in
               the msgiov array overflows a ssizet.



     The send() function returns errors under the following  con-
     ditions:




SunOS 5.11          Last change: 16 Jul 2004                    3






Sockets Library Functions                           send(3SOCKET)



     EPIPE    The socket is shut down for writing, or the  socket
              is  connection-mode  and is no longer connected. In
              the  latter  case,  if  the  socket  is   of   type
              SOCKSTREAM, the SIGPIPE signal is generated to the
              calling thread.


ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Stable                      
    
     MT-Level                     Safe                        
    


SEE ALSO
     fcntl(2),     poll(2),      write(2),      connect(3SOCKET),
     getsockopt(3SOCKET),        recv(3SOCKET),       select(3C),
     socket(3SOCKET), socket.h(3HEAD), attributes(5)





























SunOS 5.11          Last change: 16 Jul 2004                    4



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™