// Return the 4-byte IP address, converting it into host byte order. ACE_UINT32 ACE_INET_Addr::get_ip_address (void) const { ACE_TRACE ("ACE_INET_Addr::get_ip_address"); #if defined (ACE_HAS_IPV6) if (this->get_type () == AF_INET6) { if (IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr) || IN6_IS_ADDR_V4COMPAT (&this->inet_addr_.in6_.sin6_addr) ) { ACE_UINT32 addr; // Return the last 32 bits of the address char *thisaddrptr = (char*)this->ip_addr_pointer (); thisaddrptr += 128/8 - 32/8; ACE_OS::memcpy (&addr, thisaddrptr, sizeof (addr)); return ACE_NTOHL (addr); } ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_INET_Addr::get_ip_address: address is a IPv6 address not IPv4\n"))); errno = EAFNOSUPPORT; return 0; } #endif /* ACE_HAS_IPV6 */ return ACE_NTOHL (ACE_UINT32 (this->inet_addr_.in4_.sin_addr.s_addr)); }
int ACE_Name_Reply::decode (void) { ACE_TRACE ("ACE_Name_Reply::decode"); this->transfer_.length_ = ACE_NTOHL (this->transfer_.length_); this->transfer_.type_ = ACE_NTOHL (this->transfer_.type_); this->transfer_.errno_ = ACE_NTOHL (this->transfer_.errno_); return 0; }
int ACE_Name_Proxy::recv_reply (ACE_Name_Request &reply) { ACE_TRACE ("ACE_Name_Proxy::recv_reply"); // Read the first 4 bytes to get the length of the message This // implementation assumes that the first 4 bytes are the length of // the message. ssize_t n = this->peer_.recv ((void *) &reply, sizeof (ACE_UINT32)); switch (n) { case -1: // FALLTHROUGH ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("****************** recv_reply returned -1\n"))); default: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), ACE_TEXT ("recv failed"), n, sizeof (ACE_UINT32))); // FALLTHROUGH case 0: // We've shutdown unexpectedly return -1; // NOTREACHED case sizeof (ACE_UINT32): { // Transform the length into host byte order. ssize_t length = ACE_NTOHL (reply.length ()); // Receive the rest of the request message. // @@ beware of blocking read!!!. n = this->peer_.recv ((void *) (((char *) &reply) + sizeof (ACE_UINT32)), length - sizeof (ACE_UINT32)); // Subtract off the size of the part we skipped over... if (n != ssize_t (length - sizeof (ACE_UINT32))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p expected %d, got %d\n"), ACE_TEXT ("invalid length"), length, n)); return -1; } // Decode the request into host byte order. if (reply.decode () == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed"))); return -1; } } } return 0; }
int ACE_Name_Request::decode (void) { ACE_TRACE ("ACE_Name_Request::decode"); // Decode the fixed-sized portion first. this->transfer_.block_forever_ = ACE_NTOHL (this->transfer_.block_forever_); this->transfer_.usec_timeout_ = ACE_NTOHL (this->transfer_.usec_timeout_); #if defined (ACE_LITTLE_ENDIAN) ACE_UINT64 secs = this->transfer_.sec_timeout_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_); #endif this->transfer_.length_ = ACE_NTOHL (this->transfer_.length_); this->transfer_.msg_type_ = ACE_NTOHL (this->transfer_.msg_type_); this->transfer_.name_len_ = ACE_NTOHL (this->transfer_.name_len_); this->transfer_.value_len_ = ACE_NTOHL (this->transfer_.value_len_); this->transfer_.type_len_ = ACE_NTOHL (this->transfer_.type_len_); size_t nv_data_len = (this->transfer_.name_len_ + this->transfer_.value_len_) / sizeof (ACE_WCHAR_T); for (size_t i = 0; i < nv_data_len; i++) this->transfer_.data_[i] = ACE_NTOHS (this->transfer_.data_[i]); this->name_ = this->transfer_.data_; this->value_ = &this->name_[this->transfer_.name_len_ / sizeof (ACE_WCHAR_T)]; this->type_ = (char *)(&this->value_[this->transfer_.value_len_ / sizeof (ACE_WCHAR_T)]); this->type_[this->transfer_.type_len_] = '\0'; // Decode the variable-sized portion. return 0; }
// Decode the transfer buffer into host byte byte order // so that it can be used by the server. int ACE_Time_Request::decode (void) { ACE_TRACE ("ACE_Time_Request::decode"); // Decode this->transfer_.block_forever_ = ACE_NTOHL (this->transfer_.block_forever_); this->transfer_.usec_timeout_ = ACE_NTOHL (this->transfer_.usec_timeout_); this->transfer_.msg_type_ = ACE_NTOHL (this->transfer_.msg_type_); #if defined (ACE_LITTLE_ENDIAN) ACE_UINT64 secs = this->transfer_.sec_timeout_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_); secs = this->transfer_.time_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.time_); #endif this->time_ = ACE_Utils::truncate_cast<time_t> (this->transfer_.time_); return 0; }
int Server_Events::handle_input (ACE_HANDLE) { // Receive message from multicast group. iovec iovp[2]; iovp[0].iov_base = buf_; iovp[0].iov_len = sizeof (log_record_); iovp[1].iov_base = &buf_[sizeof (log_record_)]; iovp[1].iov_len = 4 * BUFSIZ - sizeof (log_record_); ssize_t retcode = this->mcast_dgram_.recv (iovp, 2, this->remote_addr_); if (retcode != -1) { total_messages_received_++; total_bytes_received_ += retcode; last_sequence_number_ = ACE_NTOHL (log_record_->sequence_number); for (char *message_end = this->message_ + ACE_OS::strlen (this->message_) - 1; ACE_OS::strchr ("\r\n \t", *message_end) != 0; ) { *message_end-- = '\0'; if (message_end == this->message_) break; } ACE_DEBUG ((LM_DEBUG, "sequence number = %d\n", last_sequence_number_)); ACE_DEBUG ((LM_DEBUG, "message = '%s'\n", this->message_)); if (this->initialized_ == 0) { // Restart the timer since we've received events again. if (reactor()->schedule_timer (this, (void *) this->hostname_, ACE_Time_Value::zero, ACE_Time_Value (DURATION)) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); this->initialized_ = 1; } this->count_ = 1; return 0; } else return -1; }
// thread function that serves the client for the UnMarshalled Octet // test static ACE_THR_FUNC_RETURN unmarshalledOctetServer (void *arg){ // unbundle the arguments ArgStruct * args = reinterpret_cast<ArgStruct *> (arg); ACE_SOCK_Stream * dataModeStream = args->stream; ACE_CDR::ULong numIterations = args->numIters; delete args; // serve the client for numIterations synchronous invocations do { // READ A MESSAGE FROM THE CLIENT size_t bt; ACE_CDR::ULong msgBufSize=0; // read the size of the buffer to follow if ((dataModeStream->recv_n(&msgBufSize, ACE_CDR::LONG_SIZE, 0, &bt)) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("recv_n")), 0); msgBufSize = ACE_NTOHL(msgBufSize); // allocate the buffer for the message payload ACE_CDR::Octet * msgBuf = 0; ACE_NEW_RETURN(msgBuf, ACE_CDR::Octet[msgBufSize], 0); // read the buffer if ((dataModeStream->recv_n(msgBuf, msgBufSize, 0, &bt)) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("recv_n")), 0); // clean up the allocated buffer delete[] msgBuf; // SEND A REPLY TO THE CLIENT // send back a 2 byte reply ACE_CDR::Short reply; if ((dataModeStream->send_n(&reply, ACE_CDR::SHORT_SIZE, 0, &bt)) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n")), 0); } while (--numIterations); // close and destroy the stream dataModeStream->close(); delete dataModeStream; return 0; }
unsigned int CRtpPacket::GetTimeStamp()const { if (NULL == m_pFixedHead) { //BP_RUN_LOG_ERR(UNDEF_ERRCODE, "CRtpPacket::GetTimeStamp","Rtp packet get timestamp fail packet is null."); return 0; } return ACE_NTOHL(m_pFixedHead->timestamp); }
int ACE_INET_Addr::set (u_short port_number, const char host_name[], int encode, int address_family) { ACE_TRACE ("ACE_INET_Addr::set"); // Yow, someone gave us a NULL host_name! if (host_name == 0) { errno = EINVAL; return -1; } this->reset_i (); ACE_OS::memset ((void *) &this->inet_addr_, 0, sizeof this->inet_addr_); #if defined (ACE_HAS_IPV6) // Let the IPv4 case fall through to the non-IPv6-capable section. // We don't need the additional getaddrinfo() capability and the Linux // getaddrinfo() is substantially slower than gethostbyname() w/ // large vlans. # if defined (ACE_USES_IPV4_IPV6_MIGRATION) if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ()) address_family = AF_INET; # endif /* ACE_USES_IPV4_IPV6_MIGRATION */ if (address_family != AF_INET) { # if defined (ACE_HAS_GETHOSTBYNAME2) hostent hentry; hostent *hp; ACE_HOSTENT_DATA buf; int h_error = 0; // Not the same as errno! if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry, buf, sizeof(buf), &hp, &h_error)) { if (hp != 0) { this->set_type (hp->h_addrtype); for (size_t i = 0; hp->h_addr_list[i]; ++i) { union ip46 next_addr; struct sockaddr_in6 *next_addr_in6 = &next_addr.in6_; (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr)); next_addr_in6->sin6_family = AF_INET6; next_addr_in6->sin6_port = encode ? ACE_NTOHS (port_number) : port_number; #ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN next_addr_in6_->sin6_len = hp->h_length; #endif (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr, hp->h_addr_list[i], hp->h_length); this->inet_addrs_.push_back (next_addr); } this->reset (); return 0; } } errno = h_error; if (address_family == AF_INET6) return -1; # else struct addrinfo hints; struct addrinfo *res = 0, *curr = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; // Note - specify the socktype here to avoid getting multiple entries // returned with the same address for different socket types or // protocols. If this causes a problem for some reason (an address that's // available for TCP but not UDP, or vice-versa) this will need to change // back to unrestricted hints and weed out the duplicate addresses by // searching this->inet_addrs_ which would slow things down. hints.ai_socktype = SOCK_STREAM; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); for (curr = res; curr; curr = curr->ai_next) { union ip46 next_addr; if (curr->ai_family == AF_INET6) { ACE_OS::memcpy (&next_addr.in6_, curr->ai_addr, curr->ai_addrlen); next_addr.in6_.sin6_port = encode ? ACE_NTOHS (port_number) : port_number; } else { ACE_OS::memcpy (&next_addr.in4_, curr->ai_addr, curr->ai_addrlen); next_addr.in4_.sin_port = encode ? ACE_NTOHS (port_number) : port_number; } this->inet_addrs_.push_back (next_addr); } this->reset (); ::freeaddrinfo (res); return 0; } if (address_family == AF_INET6) { if (res) ::freeaddrinfo(res); errno = error; return -1; } # endif /* ACE_HAS_GETHOSTBYNAME2 */ // Let AF_UNSPEC try again w/ IPv4. } #endif /* ACE_HAS_IPV6 */ // IPv6 not supported... insure the family is set to IPv4 address_family = AF_INET; this->set_type (address_family); this->inet_addr_.in4_.sin_family = static_cast<short> (address_family); #ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); #endif struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) { this->inet_addrs_iter_ = this->inet_addrs_.end (); return this->set (port_number, encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, encode); } hostent hentry; ACE_HOSTENT_DATA buf; int h_error = 0; // Not the same as errno! hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, buf, &h_error); if (hp == 0) { errno = h_error; return -1; } this->set_type (hp->h_addrtype); for (size_t i = 0; hp->h_addr_list[i]; ++i) { union ip46 next_addr; struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_; (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr)); next_addr_in->sin_family = AF_INET; next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number; (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr, hp->h_addr_list[i], hp->h_length); this->inet_addrs_.push_back (next_addr); } this->reset (); return 0; }
static ACE_THR_FUNC_RETURN oneway_server (void *arg) { ACE_INET_Addr cli_addr; ACE_SOCK_Stream new_stream; ACE_HANDLE handle = (ACE_HANDLE) (intptr_t) arg; new_stream.set_handle (handle); // Make sure we're not in non-blocking mode. if (new_stream.disable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "disable"), 0); else if (new_stream.get_remote_addr (cli_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), 0); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client %s connected from %d\n", cli_addr.get_host_name (), cli_addr.get_port_number ())); // Timer business ACE_Profile_Timer timer; timer.start (); size_t total_bytes = 0; size_t message_count = 0; char *request = 0; // Read data from client (terminate on error). for (;;) { ACE_INT32 len; ssize_t r_bytes = new_stream.recv_n ((void *) &len, sizeof (ACE_INT32)); if (r_bytes == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "recv")); break; } else if (r_bytes == 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) reached end of input, connection closed by client\n")); break; } else if (r_bytes != sizeof (ACE_INT32)) { ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "recv_n failed")); break; } else { len = ACE_NTOHL (len); ACE_NEW_RETURN (request, char [len], 0); } // Subtract off the sizeof the length prefix. r_bytes = new_stream.recv_n (request, len - sizeof (ACE_UINT32)); if (r_bytes == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "recv")); break; } else if (r_bytes == 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) reached end of input, connection closed by client\n")); break; } else if (verbose && ACE::write_n (ACE_STDOUT, request, r_bytes) != r_bytes) ACE_ERROR ((LM_ERROR, "%p\n", "ACE::write_n")); total_bytes += size_t (r_bytes); message_count++; delete [] request; request = 0; } timer.stop (); ACE_Profile_Timer::ACE_Elapsed_Time et; timer.elapsed_time (et); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\t\treal time = %f secs \n\t\tuser time = %f secs \n\t\tsystem time = %f secs\n"), et.real_time, et.user_time, et.system_time)); double messages_per_sec = double (message_count) / et.real_time; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\t\tmessages = %d\n\t\ttotal bytes = %d\n\t\tmbits/sec = %f\n\t\tusec-per-message = %f\n\t\tmessages-per-second = %0.00f\n"), message_count, total_bytes, (((double) total_bytes * 8) / et.real_time) / (double) (1024 * 1024), (et.real_time / (double) message_count) * 1000000, messages_per_sec < 0 ? 0 : messages_per_sec)); // Close new endpoint (listening endpoint stays open). new_stream.close (); delete [] request; return 0; }
void ACE_SOCK_Dgram_Mcast::dump (void) const { #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_SOCK_Dgram_Mcast::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); # if defined (ACE_SOCK_DGRAM_MCAST_DUMPABLE) ACE_TCHAR addr_string[MAXNAMELEN + 1]; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nOptions: bindaddr=%s, nulliface=%s\n"), ACE_BIT_ENABLED (this->opts_, OPT_BINDADDR_YES) ? ACE_TEXT ("<Bound>") : ACE_TEXT ("<Not Bound>"), ACE_BIT_ENABLED (this->opts_, OPT_NULLIFACE_ALL) ? ACE_TEXT ("<All Ifaces>") : ACE_TEXT ("<Default Iface>"))); // Show default send addr, port#, and interface. ACE_SDM_helpers::addr_to_string (this->send_addr_, addr_string, sizeof addr_string, 0); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Send addr=%s iface=%s\n"), addr_string, this->send_net_if_ ? this->send_net_if_ : ACE_TEXT ("<default>"))); // Show list of subscribed addresses. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Subscription list:\n"))); ACE_MT (ACE_GUARD (ACE_SDM_LOCK, guard, this->subscription_list_lock_)); subscription_list_iter_t iter (this->subscription_list_); for ( ; !iter.done (); iter.advance ()) { ACE_TCHAR iface_string[MAXNAMELEN + 1]; ip_mreq *pm = iter.next (); // Get subscribed address (w/out port# info - not relevant). ACE_INET_Addr ip_addr (static_cast<u_short> (0), ACE_NTOHL (pm->IMR_MULTIADDR.s_addr)); ACE_SDM_helpers::addr_to_string (ip_addr, addr_string, sizeof addr_string, 1); // Get interface address/specification. ACE_INET_Addr if_addr (static_cast<u_short> (0), ACE_NTOHL (pm->imr_interface.s_addr)); ACE_SDM_helpers::addr_to_string (if_addr, iface_string, sizeof iface_string, 1); if (ACE_OS::strcmp (iface_string, ACE_TEXT ("0.0.0.0")) == 0) // Receives on system default iface. (Note that null_iface_opt_ // option processing has already occurred.) ACE_OS::strcpy (iface_string, ACE_TEXT ("<default>")); // Dump info. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\taddr=%s iface=%s\n"), addr_string, iface_string)); } # endif /* ACE_SOCK_DGRAM_MCAST_DUMPABLE */ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ }
/* VIRTUAL */ int ACE_Name_Handler::recv_request (void) { ACE_TRACE (ACE_TEXT ("ACE_Name_Handler::recv_request")); // Read the first 4 bytes to get the length of the message This // implementation assumes that the first 4 bytes are the length of // the message. ssize_t n = this->peer ().recv ((void *) &this->name_request_, sizeof (ACE_UINT32)); switch (n) { case -1: /* FALLTHROUGH */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("****************** recv_request returned -1\n"))); default: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), ACE_TEXT ("recv failed"), n, sizeof (ACE_UINT32))); /* FALLTHROUGH */ case 0: // We've shutdown unexpectedly, let's abandon the connection. this->abandon (); return -1; /* NOTREACHED */ case sizeof (ACE_UINT32): { // Transform the length into host byte order. ssize_t length = ACE_NTOHL (this->name_request_.length ()); // Do a sanity check on the length of the message. if (length > (ssize_t) sizeof this->name_request_) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("length %d too long\n"), length)); return this->abandon (); } // Receive the rest of the request message. // @@ beware of blocking read!!!. n = this->peer ().recv ((void *) (((char *) &this->name_request_) + sizeof (ACE_UINT32)), length - sizeof (ACE_UINT32)); // Subtract off the size of the part we skipped over... if (n != (length - (ssize_t) sizeof (ACE_UINT32))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p expected %d, got %d\n"), ACE_TEXT ("invalid length"), length, n)); return this->abandon (); } // Decode the request into host byte order. if (this->name_request_.decode () == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed"))); return this->abandon (); } } } return 0; }
int run_main (int, ACE_TCHAR *[]) { ACE_START_TEST (ACE_TEXT ("Multihomed_INET_Addr_Test")); int status = 0; // Innocent until proven guilty // loop variables size_t i, j; sockaddr_in *pointer; // The port will always be this u_short port = 80; // The primary address will always be this const char *primary_dotted_decimal = "138.38.180.251"; // The secondary addresses will always be these... const char *secondary_dotted_decimals[] = { "64.219.54.121", "127.0.0.1", "21.242.14.51", "53.141.124.24", "42.12.44.9" }; // ... and as you can see, there are 5 of them const size_t num_secondaries = 5; // We also need the primary address and the secondary addresses // in ACE_UINT32 format in host byte order ACE_UINT32 primary_addr32; ACE_UINT32 secondary_addr32[5]; { struct in_addr addrv4; ACE_OS::memset ((void *) &addrv4, 0, sizeof addrv4); ACE_OS::inet_pton (AF_INET, primary_dotted_decimal, &addrv4); ACE_OS::memcpy (&primary_addr32, &addrv4, sizeof (primary_addr32)); primary_addr32 = ACE_NTOHL(primary_addr32); } for (i = 0; i < num_secondaries; ++i) { struct in_addr addrv4; ACE_OS::memset ((void *) &addrv4, 0, sizeof addrv4); ACE_OS::inet_pton (AF_INET, secondary_dotted_decimals[i], &addrv4); ACE_OS::memcpy (&secondary_addr32[i], &addrv4, sizeof (primary_addr32)); secondary_addr32[i] = ACE_NTOHL(secondary_addr32[i]); } // Test subject ACE_Multihomed_INET_Addr addr; // Array of ones (used to clear the secondary addresses of the test // subject) ACE_UINT32 array_of_threes[5] = { ACE_UINT32 (3), ACE_UINT32 (3), ACE_UINT32 (3), ACE_UINT32 (3), ACE_UINT32 (3) }; // Array of INET_Addrs that will repeatedly be passed into the // get_secondary_addresses accessor of Multihomed_INET_Addr ACE_INET_Addr in_out[5]; // Array of INET_Addrs against which the above array will be tested. ACE_INET_Addr stay_out[5]; // Array of sockaddrs that will repeatedly be passed into the // get_addresses accessor of Multihomed_INET_Addr const size_t num_sockaddrs = 6; sockaddr_in in_out_sockaddr[num_sockaddrs]; // Run the test with a varying number of secondary addresses for (i = 0; i <= num_secondaries; ++i) { /****** Clear the in_out array and test subject ******/ // Clear the in_out array by setting every port to 0 and every // address to 1 for (j = 0; j < num_secondaries; ++j) { in_out[j].set(0, ACE_UINT32 (1), 1); } // Clear the in_out_sockaddr array by setting every port to 0 and // every address to 1 ACE_OS::memset(in_out_sockaddr, 0, num_sockaddrs * sizeof(sockaddr)); // Clear the test subject by setting the port to 2 and every // address (both the primary and the secondaries) to 3 addr.set (2, ACE_UINT32 (3), 1, array_of_threes, num_secondaries); // Check that the port is 2 if (addr.get_port_number() != 2) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed get_port_number check\n") ACE_TEXT ("%d != %d\n"), addr.get_port_number(), 2)); status = 1; } // Check that the primary address is 3 if (addr.get_ip_address() != ACE_UINT32 (3)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed get_ip_address check\n") ACE_TEXT ("0x%x != 0x%x\n"), addr.get_ip_address(), ACE_UINT32 (3))); status = 1; } // Check that the test subject reports the correct number of // secondary addresses. size_t returned_num_secondaries = addr.get_num_secondary_addresses(); if (returned_num_secondaries == num_secondaries) { // Set a stay_out element to the state that we expect to see // from every in_out element after the in_out array is passed to // the accessor of the test subject. stay_out[0].set(2, ACE_UINT32 (3), 1); // Pass the in_out array to the accessor addr.get_secondary_addresses(in_out, num_secondaries); // Check that the in_out array matches stay_out element for (j = 0; j < num_secondaries; ++j) { if (in_out[j] != stay_out[0]) { ACE_TCHAR in_out_string[100]; ACE_TCHAR stay_out_string[100]; in_out[j].addr_to_string(in_out_string, 100); stay_out[0].addr_to_string(stay_out_string, 100); ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed get_secondary_addresses check\n") ACE_TEXT ("%s != %s\n"), in_out_string, stay_out_string)); status = 1; } } // Pass the in_out_sockaddr array to the accessor addr.get_addresses(in_out_sockaddr, num_secondaries + 1); // Check that the in_out_sockaddr array matches stay_out element for (j = 0, pointer = in_out_sockaddr; j < num_secondaries + 1; ++j, ++pointer) { if (ACE_OS::memcmp(pointer, stay_out[0].get_addr(), sizeof(sockaddr))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed get_addresses check\n"))); status = 1; } } } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed get_num_secondary_addresses check\n") ACE_TEXT ("%d != %d\n"), returned_num_secondaries, num_secondaries)); status = 1; } /**** Test set (u_short, const char[], int, int, const char *([]), size_t) ****/ addr.set(port, primary_dotted_decimal, 1, AF_INET, secondary_dotted_decimals, i); // Check the port number if (addr.get_port_number() != port) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed second get_port_number check\n") ACE_TEXT ("%d != %d\n"), addr.get_port_number(), port)); status = 1; } // Check the primary address if (0 != ACE_OS::strcmp (addr.get_host_addr(), primary_dotted_decimal)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%C failed get_host_addr() check\n") ACE_TEXT ("%C != %C\n"), primary_dotted_decimal, addr.get_host_addr (), primary_dotted_decimal)); status = 1; } // Check that the test subject reports the correct number of // secondary addresses. returned_num_secondaries = addr.get_num_secondary_addresses(); if (returned_num_secondaries == i) { // Initialize the stay_out array with the secondary addresses for (j = 0; j < i; ++j) { stay_out[j].set(port, secondary_dotted_decimals[j]); } // Pass the in_out array to the accessor addr.get_secondary_addresses(in_out, i); // Check that the in_out array matches stay_out array for (j = 0; j < i; ++j) { if (in_out[j] != stay_out[j]) { ACE_TCHAR in_out_string[100]; ACE_TCHAR stay_out_string[100]; in_out[j].addr_to_string(in_out_string, 100); stay_out[j].addr_to_string(stay_out_string, 100); ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed second get_secondary_addresses check\n") ACE_TEXT ("%s != %s\n"), in_out_string, stay_out_string)); status = 1; } } // Pass the in_out_sockaddr array to the accessor addr.get_addresses(in_out_sockaddr, i + 1); // Check that the primary address in the in_out_sockaddr array // matches the primary address reported by the superclass if (ACE_OS::memcmp(in_out_sockaddr, addr.get_addr(), sizeof(sockaddr))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed second get_addresses check ") ACE_TEXT ("(for primary address)\n"))); status = 1; } // Check that the secondary addresses in the in_out_sockaddr // array match the stay_out array for (j = 1, pointer = &in_out_sockaddr[1]; j < i + 1; ++j, ++pointer) { if (ACE_OS::memcmp(pointer, stay_out[j-1].get_addr(), sizeof(sockaddr))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed second get_addresses check ") ACE_TEXT ("(for secondary addresses)\n"))); status = 1; } } } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed second get_num_secondary_addresses check\n") ACE_TEXT ("%d != %d\n"), returned_num_secondaries, i)); status = 1; } /****** Clear the in_out array and test subject AGAIN ******/ // Clear the in_out array by setting every port to 0 and every // address to 1 for (j = 0; j < num_secondaries; ++j) { in_out[j].set(0, ACE_UINT32 (1), 1); } // Clear the test subject by setting the port to 2 and every // address (both the primary and the secondaries) to 3 addr.set (2, ACE_UINT32 (3), 1, array_of_threes, num_secondaries); // Check that the port is 2 if (addr.get_port_number() != 2) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed third get_port_number check\n") ACE_TEXT ("%d != %d\n"), addr.get_port_number(), 2)); status = 1; } // Check that the primary address is 3 if (addr.get_ip_address() != ACE_UINT32 (3)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed third get_ip_address check\n") ACE_TEXT ("0x%x != 0x%x\n"), addr.get_ip_address(), ACE_UINT32 (3))); status = 1; } // Check that the test subject reports the correct number of // secondary addresses. returned_num_secondaries = addr.get_num_secondary_addresses(); if (returned_num_secondaries == num_secondaries) { // Set a stay_out element to the state that we expect to see // from every in_out element after the in_out array is passed to // the accessor of the test subject. stay_out[0].set(2, ACE_UINT32 (3), 1); // Pass the in_out array to the accessor addr.get_secondary_addresses(in_out, num_secondaries); // Check that the in_out array matches stay_out array for (j = 0; j < num_secondaries; ++j) { if (in_out[j] != stay_out[0]) { ACE_TCHAR in_out_string[100]; ACE_TCHAR stay_out_string[100]; in_out[j].addr_to_string(in_out_string, 100); stay_out[0].addr_to_string(stay_out_string, 100); ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed third get_secondary_addresses check\n") ACE_TEXT ("%s != %s\n"), in_out_string, stay_out_string)); status = 1; } } } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed third get_num_secondary_addresses check\n") ACE_TEXT ("%d != %d\n"), returned_num_secondaries, num_secondaries)); status = 1; } /**** Test set (u_short, ACE_UINT32, int, const ACE_UINT32 *, size_t) ****/ addr.set(port, primary_addr32, 1, secondary_addr32, i); // Check the port number if (addr.get_port_number() != port) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed forth get_port_number check\n") ACE_TEXT ("%d != %d\n"), addr.get_port_number(), port)); status = 1; } // Check the primary address if (0 != ACE_OS::strcmp (addr.get_host_addr(), primary_dotted_decimal)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%C failed second get_ip_address() check\n") ACE_TEXT ("%C != %C\n"), primary_dotted_decimal, addr.get_host_addr (), primary_dotted_decimal)); status = 1; } // Check that the test subject reports the correct number of // secondary addresses. returned_num_secondaries = addr.get_num_secondary_addresses(); if (returned_num_secondaries == i) { // Initialize the stay_out array with the secondary addresses for (j = 0; j < i; ++j) { stay_out[j].set(port, secondary_addr32[j]); } // Pass the in_out array to the accessor addr.get_secondary_addresses(in_out, j); // Check that the in_out array matches stay_out array for (j = 0; j < i; ++j) { if (in_out[j] != stay_out[j]) { ACE_TCHAR in_out_string[100]; ACE_TCHAR stay_out_string[100]; in_out[j].addr_to_string(in_out_string, 100); stay_out[j].addr_to_string(stay_out_string, 100); ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed forth get_secondary_addresses check\n") ACE_TEXT ("%s != %s\n"), in_out_string, stay_out_string)); status = 1; } } } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed forth get_num_secondary_addresses check\n") ACE_TEXT ("%d != %d\n"), returned_num_secondaries, i)); status = 1; } } ACE_END_TEST; return status; }
int ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap, int protocol_family, int backlog) { ACE_TRACE ("ACE_SOCK_Acceptor::shared_open"); int error = 0; #if defined (ACE_HAS_IPV6) if (protocol_family == PF_INET6) { sockaddr_in6 local_inet6_addr; ACE_OS::memset (reinterpret_cast<void *> (&local_inet6_addr), 0, sizeof local_inet6_addr); if (local_sap == ACE_Addr::sap_any) { local_inet6_addr.sin6_family = AF_INET6; local_inet6_addr.sin6_port = 0; local_inet6_addr.sin6_addr = in6addr_any; } else local_inet6_addr = *reinterpret_cast<sockaddr_in6 *> (local_sap.get_addr ()); # if defined (ACE_WIN32) // on windows vista and later, Winsock can support dual stack sockets // but this must be explicitly set prior to the bind. Since this // behavior is the default on *nix platforms, it should be benigh to // just do it here. On older platforms the setsockopt will fail, but // that should be OK. int zero = 0; ACE_OS::setsockopt (this->get_handle (), IPPROTO_IPV6, IPV6_V6ONLY, (char *)&zero, sizeof (zero)); # endif /* ACE_WIN32 */ // We probably don't need a bind_port written here. // There are currently no supported OS's that define // ACE_LACKS_WILDCARD_BIND. if (ACE_OS::bind (this->get_handle (), reinterpret_cast<sockaddr *> (&local_inet6_addr), sizeof local_inet6_addr) == -1) error = 1; } else #endif if (protocol_family == PF_INET) { sockaddr_in local_inet_addr; ACE_OS::memset (reinterpret_cast<void *> (&local_inet_addr), 0, sizeof local_inet_addr); if (local_sap == ACE_Addr::sap_any) { local_inet_addr.sin_port = 0; } else local_inet_addr = *reinterpret_cast<sockaddr_in *> (local_sap.get_addr ()); if (local_inet_addr.sin_port == 0) { if (ACE::bind_port (this->get_handle (), ACE_NTOHL (ACE_UINT32 (local_inet_addr.sin_addr.s_addr))) == -1) error = 1; } else if (ACE_OS::bind (this->get_handle (), reinterpret_cast<sockaddr *> (&local_inet_addr), sizeof local_inet_addr) == -1) error = 1; } else if (ACE_OS::bind (this->get_handle (), (sockaddr *) local_sap.get_addr (), local_sap.get_size ()) == -1) error = 1; if (error != 0 || ACE_OS::listen (this->get_handle (), backlog) == -1) { ACE_Errno_Guard g (errno); // Preserve across close() below. error = 1; this->close (); } return error ? -1 : 0; }
int ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap, int protocol_family, int backlog) { ACE_TRACE ("ACE_SOCK_Acceptor::shared_open"); int error = 0; #if defined (ACE_HAS_IPV6) if (protocol_family == PF_INET6) { sockaddr_in6 local_inet6_addr; ACE_OS::memset (reinterpret_cast<void *> (&local_inet6_addr), 0, sizeof local_inet6_addr); if (local_sap == ACE_Addr::sap_any) { local_inet6_addr.sin6_family = AF_INET6; local_inet6_addr.sin6_port = 0; local_inet6_addr.sin6_addr = in6addr_any; } else local_inet6_addr = *reinterpret_cast<sockaddr_in6 *> (local_sap.get_addr ()); // We probably don't need a bind_port written here. // There are currently no supported OS's that define // ACE_LACKS_WILDCARD_BIND. if (ACE_OS::bind (this->get_handle (), reinterpret_cast<sockaddr *> (&local_inet6_addr), sizeof local_inet6_addr) == -1) error = 1; } else #endif if (protocol_family == PF_INET) { sockaddr_in local_inet_addr; ACE_OS::memset (reinterpret_cast<void *> (&local_inet_addr), 0, sizeof local_inet_addr); if (local_sap == ACE_Addr::sap_any) { local_inet_addr.sin_port = 0; } else local_inet_addr = *reinterpret_cast<sockaddr_in *> (local_sap.get_addr ()); if (local_inet_addr.sin_port == 0) { if (ACE::bind_port (this->get_handle (), ACE_NTOHL (ACE_UINT32 (local_inet_addr.sin_addr.s_addr))) == -1) error = 1; } else if (ACE_OS::bind (this->get_handle (), reinterpret_cast<sockaddr *> (&local_inet_addr), sizeof local_inet_addr) == -1) error = 1; } else if (ACE_OS::bind (this->get_handle (), (sockaddr *) local_sap.get_addr (), local_sap.get_size ()) == -1) error = 1; if (error != 0 || ACE_OS::listen (this->get_handle (), backlog) == -1) { ACE_Errno_Guard g (errno); // Preserve across close() below. error = 1; this->close (); } return error ? -1 : 0; }
static ACE_THR_FUNC_RETURN twoway_server (void *arg) { ACE_INET_Addr cli_addr; ACE_SOCK_Stream new_stream; ACE_HANDLE handle = (ACE_HANDLE) (intptr_t) arg; new_stream.set_handle (handle); // Make sure we're not in non-blocking mode. if (new_stream.disable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "disable"), 0); else if (new_stream.get_remote_addr (cli_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), 0); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client %s connected from %d\n", cli_addr.get_host_name (), cli_addr.get_port_number ())); size_t total_bytes = 0; size_t message_count = 0; char *request = 0; // Read data from client (terminate on error). for (;;) { ACE_INT32 len; ssize_t r_bytes = new_stream.recv_n ((void *) &len, sizeof (ACE_INT32)); if (r_bytes == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "recv")); break; } else if (r_bytes == 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) reached end of input, connection closed by client\n")); break; } else if (r_bytes != sizeof (ACE_INT32)) { ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "recv_n failed")); break; } else { len = ACE_NTOHL (len); ACE_NEW_RETURN (request, char [len], 0); } // Subtract off the sizeof the length prefix. r_bytes = new_stream.recv_n (request, len - sizeof (ACE_UINT32)); if (r_bytes == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "recv")); break; } else if (r_bytes == 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) reached end of input, connection closed by client\n")); break; } else if (verbose && ACE::write_n (ACE_STDOUT, request, r_bytes) != r_bytes) ACE_ERROR ((LM_ERROR, "%p\n", "ACE::write_n")); else if (new_stream.send_n (request, r_bytes) != r_bytes) ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); total_bytes += size_t (r_bytes); message_count++; delete [] request; request = 0; } // Close new endpoint (listening endpoint stays open). new_stream.close (); delete [] request; return 0; }
int ACE_INET_Addr::set (u_short port_number, const char host_name[], int encode, int address_family) { ACE_TRACE ("ACE_INET_Addr::set"); // Yow, someone gave us a NULL host_name! if (host_name == 0) { errno = EINVAL; return -1; } ACE_OS::memset ((void *) &this->inet_addr_, 0, sizeof this->inet_addr_); #if defined (ACE_HAS_IPV6) // Let the IPv4 case fall through to the non-IPv6-capable section. // We don't need the additional getaddrinfo() capability and the Linux // getaddrinfo() is substantially slower than gethostbyname() w/ // large vlans. # if defined (ACE_USES_IPV4_IPV6_MIGRATION) if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ()) address_family = AF_INET; # endif /* ACE_USES_IPV4_IPV6_MIGRATION */ if (address_family != AF_INET) { # if defined (ACE_HAS_GETHOSTBYNAME2) hostent hentry; hostent *hp; ACE_HOSTENT_DATA buf; int h_error = 0; // Not the same as errno! if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry, buf, sizeof(buf), &hp, &h_error)) { if (hp != 0) { struct sockaddr_in6 v6; ACE_OS::memset (&v6, 0, sizeof (v6)); v6.sin6_family = AF_INET6; (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, hp->h_addr, hp->h_length); this->set_type (hp->h_addrtype); this->set_addr (&v6, hp->h_length); this->set_port_number (port_number, encode); return 0; } } errno = h_error; if (address_family == AF_INET6) return -1; # else struct addrinfo hints; struct addrinfo *res = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); this->set_addr (res->ai_addr, ACE_Utils::truncate_cast<int>(res->ai_addrlen)); this->set_port_number (port_number, encode); ::freeaddrinfo (res); return 0; } if (address_family == AF_INET6) { if (res) ::freeaddrinfo(res); errno = error; return -1; } # endif /* ACE_HAS_GETHOSTBYNAME2 */ // Let AF_UNSPEC try again w/ IPv4. } #endif /* ACE_HAS_IPV6 */ // IPv6 not supported... insure the family is set to IPv4 address_family = AF_INET; this->set_type (address_family); this->inet_addr_.in4_.sin_family = static_cast<short> (address_family); #ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); #endif struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) return this->set (port_number, encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, encode); else { hostent hentry; ACE_HOSTENT_DATA buf; int h_error = 0; // Not the same as errno! hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, buf, &h_error); if (hp == 0) errno = h_error; if (hp == 0) { return -1; } else { (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, hp->h_addr, hp->h_length); return this->set (port_number, encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, encode); } } }
int ACE_INET_Addr::set (u_short port_number, const char host_name[], int encode, int address_family) { ACE_TRACE ("ACE_INET_Addr::set"); // Yow, someone gave us a NULL host_name! if (host_name == 0) { errno = EINVAL; return -1; } ACE_OS::memset ((void *) &this->inet_addr_, 0, sizeof this->inet_addr_); #if defined (ACE_HAS_IPV6) struct addrinfo hints; struct addrinfo *res = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); # if defined (ACE_USES_IPV4_IPV6_MIGRATION) if (address_family == AF_UNSPEC && !ACE::ipv6_enabled()) address_family = AF_INET; # endif /* ACE_USES_IPV4_IPV6_MIGRATION */ if (address_family == AF_UNSPEC || address_family == AF_INET6) { hints.ai_family = AF_INET6; error = ::getaddrinfo (host_name, 0, &hints, &res); if (error) { if (address_family == AF_INET6) { if (res) ::freeaddrinfo(res); return -1; } address_family = AF_INET; } } if (address_family == AF_INET) { hints.ai_family = AF_INET; error = ::getaddrinfo (host_name, 0, &hints, &res); if (error) { if (res) ::freeaddrinfo(res); return -1; } } this->set_type (res->ai_family); this->set_addr (res->ai_addr, res->ai_addrlen); this->set_port_number (port_number, encode); ::freeaddrinfo (res); return 0; #else /* ACE_HAS_IPV6 */ // IPv6 not supported... insure the family is set to IPv4 address_family = AF_INET; this->set_type (address_family); this->inet_addr_.in4_.sin_family = static_cast<short> (address_family); struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) return this->set (port_number, encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, encode); else { # if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME) hostent *hp = ACE_OS::gethostbyname (host_name); # else hostent hentry; ACE_HOSTENT_DATA buf; int h_error; // Not the same as errno! hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, buf, &h_error); # endif /* ACE_VXWORKS */ if (hp == 0) { return -1; } else { (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, hp->h_addr, hp->h_length); return this->set (port_number, encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, encode); } } #endif /* ACE_HAS_IPV6 */ }
template <ACE_PEER_STREAM_1, class COUNTER, ACE_SYNCH_DECL, class LMR> int ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::handle_logging_record (void) { ACE_INT32 length; // We need to use the ol' two-read trick here since TCP sockets // don't support framing natively. Note that the first call is just // a "peek" -- we don't actually remove the data until the second // call. Note that this code is portable as long as ACE_UNIT32 is // always 32 bits on both the sender and receiver side. switch (this->peer ().recv ((void *) &length, sizeof length, MSG_PEEK)) { default: case -1: ACE_ERROR_RETURN ((LM_ERROR, "%p at host %s\n", "server logger", this->host_name ()), -1); /* NOTREACHED */ case 0: ACE_ERROR_RETURN ((LM_ERROR, "closing log daemon at host %s\n", this->host_name ()), -1); /* NOTREACHED */ case sizeof length: { ACE_Log_Record lp; // Use ACE_NTOHL to get around bug in egcs 2.91.6x. length = ACE_NTOHL (length); #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) u_long count = ++this->request_count_; # if 0 ACE_DEBUG ((LM_DEBUG, "request count = %d, length = %d\n", count, length)); # endif /* 0 */ #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ // Perform the actual <recv> this time. ssize_t n = this->peer ().recv_n ((void *) &lp, length); if (n != length) ACE_ERROR_RETURN ((LM_ERROR, "%d != %d, %p at host %s\n", n, length, "server logger", this->host_name ()), -1); lp.decode (); if (lp.length () == n) { // Send the log record to the log message receiver for // processing. if (ACE_BIT_ENABLED (ACE_Log_Msg::instance ()->flags (), ACE_Log_Msg::STDERR)) receiver ().log_record (this->host_name (), lp); ostream *orig_ostream = ACE_Log_Msg::instance ()->msg_ostream (); receiver ().log_output (this->host_name (), lp, orig_ostream); } else ACE_ERROR ((LM_ERROR, "error, lp.length = %d, n = %d\n", lp.length (), n)); return n; } } ACE_NOTREACHED (return -1;) }