deps/PicklingTools170Release/M2k/udpif/udpservice.cc
int_4 UDPService::write (const void*        buf, 
                         const int_4        bytes)
{ 
  int_u4               flags (0);   
  int_4                addrlen = sizeof(remoteAddr_);
  int_4                NumBytes = -1;

  if (validRemoteHost_) {
    try {
      //
      // sendTo()   returns;  n > 0:  # bytes read
      //                      n = 0:  no data written; EWOULDBLOCK or EAGAIN
      //                              from NONBLOCK socket setting, maybe..
      //                      n < 0:  "something wicked this way comes..."
      //                              sets errno
      //
      NumBytes = UDPSocketLib::UDP_sendTo (private_->socket_fd,
                                           (unsigned char *)buf, 
                                           bytes, 
                                           flags, 
                                           &remoteAddr_, 
                                           addrlen);

    } catch (const SocketLowLevelEx& e) {
        log_.error ("UDPService::[write]- Failed UDP write to <"+ RemoteIdentifier() + ">");
        log_.error ("UDPService::[write]- " + e.problem());
      }

  } else {
    log_.warning("UDPService::[write]- Invalid RemoteHost; Unable to write to <" + 
                 RemoteIdentifier() + ">");
  }

  return NumBytes;

}
//
// Preconditions: 
//
// Postconditions:
//
// Parameters:
//   const void*  buf      IN;     buffer of data to send
//   const int_4  bytes    IN;     number bytes in buf to send
//
// Description:
//   Send data in buf over network using UDP from Host:Port to
//   destination defined by attributes RemoteHost:RemotePort
//
//


const void*  buf      IN;     buffer of data to send
const int_4  bytes    IN;     number bytes in buf to send

Send data in buf over network using UDP from Host:Port to
destination defined by attributes RemoteHost:RemotePort
const void * buf IN ; buffer of data to send const int_4 bytes IN ; number bytes in buf to send Send data in buf over network using UDP from Host : Port to destination defined by attributes RemoteHost : RemotePort
int_4 UDPService::write (const void*        buf, 
                         const int_4        bytes)
{ 
  int_u4               flags (0);   
  int_4                addrlen = sizeof(remoteAddr_);
  int_4                NumBytes = -1;
  if (validRemoteHost_) {
    try {
       sendTo()   returns;  n > 0:  # bytes read
                            n = 0:  no data written; EWOULDBLOCK or EAGAIN
                                    from NONBLOCK socket setting, maybe..
                            n < 0:  "something wicked this way comes..."
                                    sets errno
      NumBytes = UDPSocketLib::UDP_sendTo (private_->socket_fd,
                                           (unsigned char *)buf, 
                                           bytes, 
                                           flags, 
                                           &remoteAddr_, 
                                           addrlen);
    } catch (const SocketLowLevelEx& e) {
        log_.error ("UDPService::[write]- Failed UDP write to <"+ RemoteIdentifier() + ">");
        log_.error ("UDPService::[write]- " + e.problem());
      }
  } else {
    log_.warning("UDPService::[write]- Invalid RemoteHost; Unable to write to <" + 
                 RemoteIdentifier() + ">");
  }
  return NumBytes;
}
int_4 UDPService :: write ( const void * buf , const int_4 bytes ) { int_u4 flags ( 0 ) ; int_4 addrlen = sizeof ( remoteAddr_ ) ; int_4 NumBytes = -1 ; if ( validRemoteHost_ ) { try { NumBytes = UDPSocketLib :: UDP_sendTo ( private_ -> socket_fd , ( unsigned char * ) buf , bytes , flags , & remoteAddr_ , addrlen ) ; } catch ( const SocketLowLevelEx & e ) { log_ . error ( " " + RemoteIdentifier ( ) + " " ) ; log_ . error ( " " + e . problem ( ) ) ; } } else { log_ . warning ( " " + RemoteIdentifier ( ) + " " ) ; } return NumBytes ; }
Preconditions:
Postconditions:
Preconditions : Postconditions :
// // sendTo()   returns;  n > 0:  # bytes read //                      n = 0:  no data written; EWOULDBLOCK or EAGAIN //                              from NONBLOCK socket setting, maybe.. //                      n < 0:  "something wicked this way comes..." //                              sets errno //