deps/PicklingTools170Release/M2k/udpif/udpservice.cc
int_4 UDPService::readFrom (void*               buf, 
                            const int_4         bytes,
                            const int_u4        flags,   
                            struct sockaddr_in* clientAddr, 
                            const int_4         clientAddrLength)
{ 
  int_4                NumBytes = -1;

  try {
    //
    // recvfrom() returns;  n > 0:  # bytes read
    //                      n = 0:  no msg avail or peer has done 
    //                              orderly shutdown (TCP only)
    //                      n < 0:  "something wicked this way comes..."
    //                              sets errno
    //
    NumBytes = UDPSocketLib::UDP_recvFrom   (private_->socket_fd,
                                             (unsigned char *)buf, 
                                             bytes, 
                                             flags, 
                                             clientAddr, 
                                             clientAddrLength);

  } catch (const SocketLowLevelEx& e) {
      log_.error ("UDPService::[readFrom]- Read error; "+e.problem());
    }

  // ERROR- UDP socket read error
  if (NumBytes < 0) {
    log_.error("UDPService::[readFrom] - Read error on UDP socket; Close port= <"+Stringize(port_)+"");
    closeNetworkPort_();
    //throw SocketLowLevelEx(identifier(), bytes);
  }


  return NumBytes;

}
//
// Preconditions: 
//
// Postconditions:
//
// Parameters:
//   void*               buf               IN;  buffer of data to send
//   const int_4         bytes             IN;  size of data buffer "buf"
//   const int_u4        flags             IN;  read flags consistent with
//                                              recvfrom() network IF call;
//                                              most commonly used would be MSG_PEEK
//   struct sockaddr_in* clientAddr        OUT; network source address of sender
//   const int_4         clientAddrLength  OUT; length of source address struct
//
// Description:
//   Get data in from UDP network interface SW and return in "buf"
//   array.  Returns sender address info to application.
//
//   This is an overloaded variant to return network "ready" sockaddr_in
//   structure so application can respond to sender, if desired.
//
//   returns;  n > 0:  # bytes read
//             n = 0:  no msg avail (e.g. NONBLOCKING socket).
//             n < 0:  "something wicked this way comes..."
//                     sets errno; throws exception
//
//


void*               buf               IN;  buffer of data to send
const int_4         bytes             IN;  size of data buffer "buf"
const int_u4        flags             IN;  read flags consistent with
recvfrom() network IF call;
most commonly used would be MSG_PEEK
struct sockaddr_in* clientAddr        OUT; network source address of sender
const int_4         clientAddrLength  OUT; length of source address struct

Get data in from UDP network interface SW and return in "buf"
array.  Returns sender address info to application.

This is an overloaded variant to return network "ready" sockaddr_in
structure so application can respond to sender, if desired.

returns;  n > 0:  # bytes read
n = 0:  no msg avail .
n < 0:  "something wicked this way comes..."
sets errno; throws exception
void * buf IN ; buffer of data to send const int_4 bytes IN ; size of data buffer " buf " const int_u4 flags IN ; read flags consistent with recvfrom () network IF call ; most commonly used would be MSG_PEEK struct sockaddr_in * clientAddr OUT ; network source address of sender const int_4 clientAddrLength OUT ; length of source address struct Get data in from UDP network interface SW and return in " buf " array . Returns sender address info to application . This is an overloaded variant to return network " ready " sockaddr_in structure so application can respond to sender if desired . returns ; n > 0 : # bytes read n = 0 : no msg avail . n < 0 : " something wicked this way comes ... " sets errno ; throws exception
int_4 UDPService::readFrom (void*               buf, 
                            const int_4         bytes,
                            const int_u4        flags,   
                            struct sockaddr_in* clientAddr, 
                            const int_4         clientAddrLength)
{ 
  int_4                NumBytes = -1;
  try {
     recvfrom() returns;  n > 0:  # bytes read
                          n = 0:  no msg avail or peer has done 
                                  orderly shutdown (TCP only)
                          n < 0:  "something wicked this way comes..."
                                  sets errno
    NumBytes = UDPSocketLib::UDP_recvFrom   (private_->socket_fd,
                                             (unsigned char *)buf, 
                                             bytes, 
                                             flags, 
                                             clientAddr, 
                                             clientAddrLength);
  } catch (const SocketLowLevelEx& e) {
      log_.error ("UDPService::[readFrom]- Read error; "+e.problem());
    }
   ERROR- UDP socket read error
  if (NumBytes < 0) {
    log_.error("UDPService::[readFrom] - Read error on UDP socket; Close port= <"+Stringize(port_)+"");
    closeNetworkPort_();
    throw SocketLowLevelEx(identifier(), bytes);
  }
  return NumBytes;
}
int_4 UDPService :: readFrom ( void * buf , const int_4 bytes , const int_u4 flags , struct sockaddr_in * clientAddr , const int_4 clientAddrLength ) { int_4 NumBytes = -1 ; try { NumBytes = UDPSocketLib :: UDP_recvFrom ( private_ -> socket_fd , ( unsigned char * ) buf , bytes , flags , clientAddr , clientAddrLength ) ; } catch ( const SocketLowLevelEx & e ) { log_ . error ( " " + e . problem ( ) ) ; } if ( NumBytes < 0 ) { log_ . error ( " " + Stringize ( port_ ) + " " ) ; closeNetworkPort_ ( ) ; } return NumBytes ; }
Preconditions:
Postconditions:
Preconditions : Postconditions :
// // recvfrom() returns;  n > 0:  # bytes read //                      n = 0:  no msg avail or peer has done  //                              orderly shutdown (TCP only) //                      n < 0:  "something wicked this way comes..." //                              sets errno // // ERROR- UDP socket read error //throw SocketLowLevelEx(identifier(), bytes);