(libc.info.gz) Receiving Datagrams

Info Catalog (libc.info.gz) Sending Datagrams (libc.info.gz) Datagrams (libc.info.gz) Datagram Example
 
 16.10.2 Receiving Datagrams
 ---------------------------
 
 The 'recvfrom' function reads a packet from a datagram socket and also
 tells you where it was sent from.  This function is declared in
 'sys/socket.h'.
 
  -- Function: ssize_t recvfrom (int SOCKET, void *BUFFER, size_t SIZE,
           int FLAGS, struct sockaddr *ADDR, socklen_t *LENGTH-PTR)
      Preliminary: | MT-Safe | AS-Safe | AC-Safe |  POSIX Safety
      Concepts.
 
      The 'recvfrom' function reads one packet from the socket SOCKET
      into the buffer BUFFER.  The SIZE argument specifies the maximum
      number of bytes to be read.
 
      If the packet is longer than SIZE bytes, then you get the first
      SIZE bytes of the packet and the rest of the packet is lost.
      There's no way to read the rest of the packet.  Thus, when you use
      a packet protocol, you must always know how long a packet to
      expect.
 
      The ADDR and LENGTH-PTR arguments are used to return the address
      where the packet came from.   Socket Addresses.  For a
      socket in the local domain the address information won't be
      meaningful, since you can't read the address of such a socket
      ( Local Namespace).  You can specify a null pointer as the
      ADDR argument if you are not interested in this information.
 
      The FLAGS are interpreted the same way as for 'recv' ( Socket
      Data Options).  The return value and error conditions are also
      the same as for 'recv'.
 
      This function is defined as a cancellation point in multi-threaded
      programs, so one has to be prepared for this and make sure that
      allocated resources (like memory, files descriptors, semaphores or
      whatever) are freed even if the thread is canceled.
 
    You can use plain 'recv' ( Receiving Data) instead of
 'recvfrom' if you don't need to find out who sent the packet (either
 because you know where it should come from or because you treat all
 possible senders alike).  Even 'read' can be used if you don't want to
 specify FLAGS ( I/O Primitives).
 
Info Catalog (libc.info.gz) Sending Datagrams (libc.info.gz) Datagrams (libc.info.gz) Datagram Example
automatically generated by info2html