Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ send(2) — CLIX 3.1r7.6.22

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fcntl(2)

recv(2)

writev(2)

select(2)

getsockopt(2)

socket(2)



  send(2)                             CLIX                             send(2)



  NAME

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

  LIBRARY

    Berkeley Software Distribution Library (libbsd.a)

  SYNOPSIS

    #include <sys/types.h>

    #include <sys/socket.h>

    int send(
      int s ,
      char *msg ,
      int len ,
      int flags );

    int sendto(
      int s ,
      char *msg ,
      int len ,
      int flags ,
      struct sockaddr *to ,
      int tolen );

    int sendmsg(
      int s ,
      struct msghdr msg[] ,
      int flags );

  PARAMETERS

    s       Represents a socket descriptor.

    msg     Points to the message to be sent.

    len     Specifies the size of the message to be sent.

    flags   Specifies a flag marking out-of-band data.

    to      Specifies the address of the target.

    tolen   Specifies the amount of space pointed to by to.

  DESCRIPTION

    The send(), sendto(), and sendmsg() functions are used to transmit a
    message to another socket.  The send() function may be used only when the



  2/94 - Intergraph Corporation                                              1






  send(2)                             CLIX                             send(2)



    socket is in a connected state, while sendto() and sendmsg() may be used
    any time.

    The address of the target is given by to, with tolen specifying the size.
    The length of the message is given by len.

    No indication of failure to deliver is implicit in a send().  Return
    values of -1 indicate certain locally detected errors.

    If no message space to hold the message to be transmitted is available to
    the socket, send() normally blocks unless the socket has been placed in
    nonblocking I/O mode.  The select() call may be used to determine when it
    is possible to send more data.

    The flags parameter may be set to the following:

    #define MSG_OOB  0x1  /* process out-of-band data */

    The flag MSG_OOB is used to send out-of-band data on sockets that support
    this notion (such as SOCK_STREAM) (see the <socket.h> header file); the
    underlying protocol must also support out-of-band data.

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

  EXAMPLES

    To send the message "hello":

    #define DATA "hello"

    if (send(sd, DATA, sizeof(DATA), 0) == -1)
         perror("Send failed");


  RETURN VALUES

    Upon successful completion, the number of bytes sent is returned.
    Otherwise, a value of -1 is returned and errno is set to indicate the
    error.

  ERRORS

    Each of these calls fail if one or more of the following is true:

    [EBADF]
           The descriptor is not valid.

    [ENOTSOCK]
           The descriptor references a file, not a socket.

    [EWOULDBLOCK]



  2                                              Intergraph Corporation - 2/94






  send(2)                             CLIX                             send(2)



           The socket is marked nonblocking and the requested operation would
           block.

    [EFAULT]
           An invalid user space address was specified.

    [EPIPE]
           The connection has been broken and no more data can be sent.

    [EINVAL]
           The maximum number of scatter gather locations has been exceeded.

    [ENOTCONN]
           Attempting to send data on a stream socket that is not connected.

    [EDESTADDRREQ]
           Attempting to send data on a datagram socket without a destination
           address.

    [EINTR]
           A signal was caught during the send(), sendto(), or sendmsg()
           functions.

    [EISCONN]
           Attempting to perform a sendto() call on a connected socket.

  RELATED INFORMATION

    Functions:  fcntl(2), recv(2), writev(2), select(2), getsockopt(2),
    socket(2)
























  2/94 - Intergraph Corporation                                              3




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026