bool CControlListen::AddListen( const char* pListenIP, uint32 u4Port, uint8 u1IPType, int nPacketParseID) { bool blState = App_ConnectAcceptorManager::instance()->CheckIPInfo(pListenIP, u4Port); if(true == blState) { //当前监听已经存在,不可以重复建设 OUR_DEBUG((LM_INFO, "[CServerManager::AddListen](%s:%d) is exist.\n", pListenIP, u4Port)); return false; } ACE_INET_Addr listenAddr; //判断IPv4还是IPv6 int nErr = 0; if (u1IPType == TYPE_IPV4) { nErr = listenAddr.set(u4Port, pListenIP); } else { nErr = listenAddr.set(u4Port, pListenIP, 1, PF_INET6); } if (nErr != 0) { OUR_DEBUG((LM_INFO, "[CControlListen::AddListen](%s:%d)set_address error[%d].\n", pListenIP, u4Port, errno)); return false; } //得到接收器 ConnectAcceptor* pConnectAcceptor = App_ConnectAcceptorManager::instance()->GetNewConnectAcceptor(); if (NULL == pConnectAcceptor) { OUR_DEBUG((LM_INFO, "[CControlListen::AddListen](%s:%d)pConnectAcceptor is NULL.\n", pListenIP, u4Port)); return false; } pConnectAcceptor->SetPacketParseInfoID(nPacketParseID); int nRet = pConnectAcceptor->open2(listenAddr, App_ReactorManager::instance()->GetAce_Reactor(REACTOR_CLIENTDEFINE), ACE_NONBLOCK, (int)GetXmlConfigAttribute(xmlNetWorkMode)->BackLog); if (-1 == nRet) { OUR_DEBUG((LM_INFO, "[CControlListen::AddListen] Listen from [%s:%d] error(%d).\n", listenAddr.get_host_addr(), listenAddr.get_port_number(), errno)); return false; } OUR_DEBUG((LM_INFO, "[CControlListen::AddListen] Listen from [%s:%d] OK.\n", listenAddr.get_host_addr(), listenAddr.get_port_number())); return true; }
int MyAcceptor::handleConnection() { int newConnSock = acceptConnection(); if (newConnSock <= 0) { PAS_ERROR2( "MyAcceptor:: accept ERROR %s. new sock fd = %d", ACE_OS::strerror(ACE_OS::last_error()), newConnSock); usleep(100000); return -1; } /// 단말기의 IP 주소를 구하기. ACE_SOCK_STREAM sock(newConnSock); ACE_INET_Addr peer; sock.get_remote_addr( peer ); PAS_INFO4( "Accept %s:%d sock=%d conn[%d] ", peer.get_host_addr(), peer.get_port_number(), newConnSock, numAccepts); numAccepts++; if (numAccepts > 10000 * 10000 * 10) numAccepts = 0; // L4 Health check ignore Config *conf = Config::instance(); if( !strcmp(peer.get_host_addr(), conf->network.L4Addr1.toStr()) || !strcmp(peer.get_host_addr(), conf->network.L4Addr2.toStr()) ) { #if 0 // set SO_LINGER - 2 sec. WIGCS 로부터 받은 팁. 2007.1.12 linger lingtime; lingtime.l_onoff = 1; lingtime.l_linger = 2; sock.set_option( SOL_SOCKET, SO_LINGER, (void*)&lingtime, sizeof(linger) ); #endif sock.close_writer(); sock.close(); PAS_INFO3( "Close L4 %s:%d sock=%d", peer.get_host_addr(), peer.get_port_number(), newConnSock); return 0; } ReactorInfo* rInfo = ReactorPool::instance()->workerReactor(); ClientHandler* pClientEH = new ClientHandler(rInfo); pClientEH->init(newConnSock); // reactor에 새로운 client 등록 // pClientEH 는 소켓이 종료될때 스스로 자신을 메모리에서 삭제한다. rInfo->pReactor->register_handler(pClientEH, READ_MASK); return 0; }
int YARPNameClient::_checkInMcast(const YARPString &s, ACE_INET_Addr &addr) { YNC("YNC %s:%d --> _checkIn %s\n",__FILE__,__LINE__,s.c_str()); YARPNameServiceCmd tmpCmd; YARPNameTCP tmpRqst; if (connect_to_server()!=0) return YARP_FAIL; tmpRqst.setName(s); tmpRqst.setIp(addr.get_host_addr()); tmpCmd.cmd = YARPNSRegister; tmpCmd.type = YARP_MCAST; tmpCmd.length = tmpRqst.length(); // send message length ACE_OS::memcpy(data_buf_,&tmpCmd, sizeof(YARPNameServiceCmd)); ACE_OS::memcpy(data_buf_+sizeof(YARPNameServiceCmd), &tmpRqst, tmpRqst.length()); iovec iov[1]; iov[0].iov_base = data_buf_; iov[0].iov_len = sizeof(YARPNameServiceCmd)+tmpRqst.length(); int sent = client_stream_.sendv_n (iov, 1); if (sent == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n","send_n"),0); ////////////////////////////////////////// unsigned int byte_count = 0; int res = 0; ACE_OS::memset(data_buf_, 0, SIZE_BUF); iov[0].iov_len = sizeof(YARPNameServiceCmd); res = client_stream_.recvv_n(iov, 1, 0, &byte_count); iov[0].iov_len = tmpCmd.length; res = client_stream_.recvv_n(iov, 1, 0, &byte_count); YARPNameTCP *tmpRpl = (YARPNameTCP *)data_buf_; tmpRpl->getAddr(addr); NAME_CLIENT_DEBUG(("Received %s(%s):%d\n", addr.get_host_addr(), servicetypeConverter(tmpCmd.type), addr.get_port_number())); // close the connection close(); return YARP_OK; }
bool P2pEndpoint::readMessage(ACE_INET_Addr& peerAddr, ACE_Message_Block& mblock) { assert(mblock.size() >= P2pConfig::defaultMtu); const ssize_t recvSize = udp_->recv(mblock.wr_ptr(), mblock.space(), peerAddr); if (recvSize == 0) { return false; } if (recvSize < 0) { const int error = ACE_OS::last_error(); if (error == EWOULDBLOCK) { return false; } //if (error == ECONNRESET) { // return false; //} NSRPC_LOG_ERROR4( ACE_TEXT("P2pEndpoint::readMessage(from: %s:%d) FAILED!!!(%d,%m)"), peerAddr.get_host_addr(), peerAddr.get_port_number(), ACE_OS::last_error()); return false; } mblock.wr_ptr(recvSize); return true; }
int RealmSocket::open(void * arg) { ACE_INET_Addr addr; if (peer().get_remote_addr(addr) == -1) { sLog->outError(LOG_FILTER_AUTHSERVER, "Error %s while opening realm socket!", ACE_OS::strerror(errno)); return -1; } _remoteAddress = addr.get_host_addr(); _remotePort = addr.get_port_number(); // Register with ACE Reactor if (Base::open(arg) == -1) return -1; if (session_) session_->OnAccept(); // reactor takes care of the socket from now on remove_reference(); return 0; }
int TAO_SCIOP_Endpoint::set (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) { char tmp_host[MAXHOSTNAMELEN + 1]; if (use_dotted_decimal_addresses || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) { const char *tmp = addr.get_host_addr (); if (tmp == 0) { if (TAO_debug_level > 0) TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\nTAO (%P|%t) ") ACE_TEXT ("SCIOP_Endpoint::set ") ACE_TEXT ("- %p\n\n"), ACE_TEXT ("cannot determine hostname"))); return -1; } else this->host_ = tmp; } else this->host_ = CORBA::string_dup (tmp_host); this->port_ = addr.get_port_number(); return 0; }
int RealmSocket::open(void * arg) { ACE_INET_Addr addr; if (peer ().get_remote_addr (addr) == -1) { sLog.outError ("RealmSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno)); return -1; } remote_address_ = addr.get_host_addr(); // Register with ACE Reactor if (Base::open(arg) == -1) return -1; if (session_ != NULL) { session_->OnAccept(); } // reactor takes care of the socket from now on remove_reference(); return 0; }
int send_dgram (ACE_SOCK_Dgram &socket, ACE_INET_Addr addr, int done = 0) { // Send each message twice, once to the right port, and once to the "wrong" // port. This helps generate noise and lets us see if port filtering is // working properly. const char *address = addr.get_host_addr (); int port = addr.get_port_number (); for (int i = 0; i < 2; ++i) { char buf[MAX_STRING_SIZE]; if (done) buf[0] = 0; else ACE_OS::sprintf (buf, "%s/%d", address, port); if (socket.send (buf, ACE_OS::strlen (buf),addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Send to %C, %p\n"), address, ACE_TEXT ("send_dgram - error calling send on ") ACE_TEXT ("ACE_SOCK_Dgram.")), -1); addr.set_port_number (++port); } return 0; }
/*virtual*/ int RealmSocket::open(void * arg) { if(Base::open(arg) == -1) return -1; ACE_INET_Addr addr; if(peer().get_remote_addr(addr) == -1) return -1; char address[1024]; addr.get_host_addr(address, 1024); this->remote_address_ = address; if(this->session_ != NULL) { // Prepare for upcall this->add_reference(); ACE_Event_Handler_var guard(this); this->session_->OnAccept(); } this->remove_reference(); return 0; }
CLocalIPPort CAceTCPServer::GetLocalIPPort(ACE_SOCK_Stream* ppeer){ CLocalIPPort local; ACE_INET_Addr raddr; ppeer->get_local_addr(raddr); local.IP = raddr.get_host_addr(); local.port = raddr.get_port_number(); return local; }
int YARPNameClient::_query(const YARPString &s, ACE_INET_Addr &addr, int *type) { YNC("YNC %s:%d --> _query %s\n",__FILE__,__LINE__,s.c_str()); YARPNameServiceCmd tmpCmd; YARPNameTCP tmpRqst; if (alt_client.isActive()) { return alt_client.queryName(s.c_str(),addr,type); } if (connect_to_server()!=0) return YARP_FAIL; tmpRqst.setName(s); tmpCmd.cmd = YARPNSQuery; tmpCmd.type = YARP_TCP; // TCP, UDP, MCAST queries are handled in the same way tmpCmd.length = tmpRqst.length(); // send message length ACE_OS::memcpy(data_buf_,&tmpCmd, sizeof(YARPNameServiceCmd)); ACE_OS::memcpy(data_buf_+sizeof(YARPNameServiceCmd), &tmpRqst, tmpRqst.length()); iovec iov[1]; iov[0].iov_base = data_buf_; iov[0].iov_len = sizeof(YARPNameServiceCmd)+tmpRqst.length(); int sent = client_stream_.sendv_n (iov, 1); if (sent == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n","send_n"),0); ////////////////////////////////////////// unsigned int byte_count = 0; int res = 0; ACE_OS::memset(data_buf_, 0, SIZE_BUF); iov[0].iov_len = sizeof(YARPNameServiceCmd); res = client_stream_.recvv_n(iov, 1, 0, &byte_count); YARPNameServiceCmd *srvCmd = (YARPNameServiceCmd *)data_buf_; *type = srvCmd->type; // get address type iov[0].iov_len = srvCmd->length; res = client_stream_.recvv_n(iov, 1, 0, &byte_count); YARPNameTCP *srvRpl = (YARPNameTCP *)data_buf_; srvRpl->getAddr(addr); NAME_CLIENT_DEBUG(("underlying ip %s port %d\n", srvRpl->_ip, srvRpl->_port)); NAME_CLIENT_DEBUG(("Received %s(%s):%d\n", addr.get_host_addr(), servicetypeConverter(*type), addr.get_port_number())); // close the connection close(); return YARP_OK; }
int open (void) { ACE_INET_Addr ClientaddrRemote; this->peer().get_remote_addr(ClientaddrRemote); ACE_OS::printf("[CConnectHandler::open] Connection from [%s:%d]\n", ClientaddrRemote.get_host_addr(), ClientaddrRemote.get_port_number()); //注册读就绪回调函数 return this->reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK); }
void TAO_UIPMC_Endpoint::object_addr (const ACE_INET_Addr &addr) { this->port_ = addr.get_port_number(); char tmp[INET6_ADDRSTRLEN]; addr.get_host_addr (tmp, sizeof tmp); this->host_ = CORBA::string_dup (tmp); this->object_addr_.set (addr); this->uint_ip_addr (addr.get_ip_address ()); }
int YARPNameClient::check_in_udp(const YARPString &name, const ACE_INET_Addr ®_addr, ACE_INET_Addr &addr, NetInt32 *ports, NetInt32 n) { YNC("YNC %s:%d --> check in %s\n",__FILE__,__LINE__,name.c_str()); int ret = YARP_FAIL; mutex_.Wait(); YARPString ip = reg_addr.get_host_addr(); ret = _checkInUdp(name, ip, ports, n); addr.set (ports[0], ip.c_str()); mutex_.Post(); return ret; }
/*virtual*/ int BufferedSocket::open(void* arg) { if (Base::open(arg) == -1) return -1; ACE_INET_Addr addr; if (peer().get_remote_addr(addr) == -1) return -1; char address[1024]; addr.get_host_addr(address, 1024); _remoteAddress = addr.get_host_addr(); this->OnAccept(); return 0; }
int Make_Common_Dispose_Client_WorkTread_Message(uint16 u2CommandID, uint32 u4ServerID, ACE_Message_Block* pmblk, ACE_INET_Addr& AddrRemote) { //组织数据 CMessage* pMessage = App_MessageServiceGroup::instance()->CreateMessage(u4ServerID, CONNECT_IO_TCP); if (NULL == pMessage) { //放入消息框架失败 OUR_DEBUG((LM_ERROR, "[CConnectClient::SendMessageGroup] ConnectID = %d CreateMessage fail.\n", u4ServerID)); App_MessageBlockManager::instance()->Close(pmblk); return -1; } else { ACE_Message_Block* pMBBHead = App_MessageBlockManager::instance()->Create(sizeof(uint32)); if (NULL == pMBBHead) { OUR_DEBUG((LM_ERROR, "[CConnectClient::SendMessageGroup] ConnectID = %d pMBBHead fail.\n", u4ServerID)); App_MessageBlockManager::instance()->Close(pmblk); return -1; } //添加消息包头 uint32 u4PacketLen = (uint32)pmblk->length(); memcpy_safe((char*)&u4PacketLen, sizeof(uint32), pMBBHead->wr_ptr(), sizeof(uint32)); pMBBHead->wr_ptr(sizeof(uint32)); sprintf_safe(pMessage->GetMessageBase()->m_szListenIP, MAX_BUFF_20, "%s", AddrRemote.get_host_addr()); sprintf_safe(pMessage->GetMessageBase()->m_szIP, MAX_BUFF_20, "127.0.0.1"); pMessage->GetMessageBase()->m_u2Cmd = u2CommandID; pMessage->GetMessageBase()->m_u4ConnectID = u4ServerID; pMessage->GetMessageBase()->m_u4ListenPort = (uint32)AddrRemote.get_port_number(); pMessage->GetMessageBase()->m_tvRecvTime = ACE_OS::gettimeofday(); pMessage->GetMessageBase()->m_u1ResouceType = RESOUCE_FROM_SERVER; pMessage->GetMessageBase()->m_u4HeadSrcSize = sizeof(uint32); pMessage->GetMessageBase()->m_u4BodySrcSize = u4PacketLen; pMessage->SetPacketHead(pMBBHead); pMessage->SetPacketBody(pmblk); //将要处理的消息放入消息处理线程 if (false == App_MessageServiceGroup::instance()->PutMessage(pMessage)) { OUR_DEBUG((LM_ERROR, "[CConnectClient::SendMessageGroup] App_MessageServiceGroup::instance()->PutMessage Error.\n")); App_MessageServiceGroup::instance()->DeleteMessage(u4ServerID, pMessage); return -1; } } return 0; }
int RASocket::open(void *) { ACE_INET_Addr remoteAddress; if (peer().get_remote_addr(remoteAddress) == -1) { sLog->outError("RASocket::open: peer().get_remote_addr error is %s", ACE_OS::strerror(errno)); return -1; } sLog->outRemote("Incoming connection from %s", remoteAddress.get_host_addr()); return activate(); }
int CProConsoleConnectAcceptor::validate_connection (const ACE_Asynch_Accept::Result& result, const ACE_INET_Addr &remote, const ACE_INET_Addr& local) { //如果不在服务器允许的IP范围中,则不需链接 if(App_MainConfig::instance()->CompareConsoleClinetIP(remote.get_host_addr()) == false) { return -1; } else { return 0; } }
int RASocket::open(void *) { ACE_INET_Addr remoteAddress; if (peer().get_remote_addr(remoteAddress) == -1) { TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "RASocket::open: peer().get_remote_addr error is %s", ACE_OS::strerror(errno)); return -1; } TC_LOG_INFO(LOG_FILTER_REMOTECOMMAND, "Incoming connection from %s", remoteAddress.get_host_addr()); return activate(); }
int RASocket::open(void *) { ACE_INET_Addr remoteAddress; if (peer().get_remote_addr(remoteAddress) == -1) { TC_LOG_ERROR("server.worldserver", "RASocket::open: peer().get_remote_addr error is %s", ACE_OS::strerror(errno)); return -1; } TC_LOG_INFO("commands.ra", "Incoming connection from %s", remoteAddress.get_host_addr()); return activate(); }
/* * Advance the address by 1, e.g., 239.255.0.1 => 239.255.0.2 * Note that the algorithm is somewhat simplistic, but sufficient for our * purpose. */ int advance_addr (ACE_INET_Addr &addr) { int a, b, c, d; ::sscanf (addr.get_host_addr (), "%d.%d.%d.%d", &a, &b, &c, &d); if (d < 255) ++d; else if (c < 255) { d = 1; ++c; } else if (b < 255) { d = 1; c = 0; ++b; } else if (a < 239) { d = 1; c = 0; b = 0; ++a; } else ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("advance_addr - Cannot advance multicast ") ACE_TEXT ("group address past %s\n"), addr.get_host_addr ()), -1); ACE_TCHAR buf[MAX_STRING_SIZE]; ACE_OS::sprintf (buf, ACE_TEXT ("%d.%d.%d.%d:%d"), a, b, c, d, addr.get_port_number ()); addr.set (buf); return 0; }
int TAO_IIOP_Endpoint::set (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) { char tmp_host[MAXHOSTNAMELEN + 1]; #if defined (ACE_HAS_IPV6) this->is_ipv6_decimal_ = false; // Reset #endif /* ACE_HAS_IPV6 */ if (use_dotted_decimal_addresses || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) { if (use_dotted_decimal_addresses == 0 && TAO_debug_level > 5) { TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - IIOP_Endpoint::set, ") ACE_TEXT ("%p\n"), ACE_TEXT ("cannot determine hostname"))); } const char *tmp = addr.get_host_addr (); if (tmp == 0) { if (TAO_debug_level > 0) { TAOLIB_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) - IIOP_Endpoint::set, ") ACE_TEXT ("%p\n"), ACE_TEXT ("cannot determine hostname and hostaddr"))); } return -1; } else { this->host_ = tmp; #if defined (ACE_HAS_IPV6) if (addr.get_type () == PF_INET6) this->is_ipv6_decimal_ = true; #endif /* ACE_HAS_IPV6 */ } } else this->host_ = CORBA::string_dup (tmp_host); this->port_ = addr.get_port_number(); return 0; }
char* IIOP_Current_Impl::local_host (void) { #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0) TAO_IIOP_Connection_Handler *iiopch = this->handler (); ACE_INET_Addr a; iiopch->peer ().get_local_addr (a); return CORBA::string_dup (a.get_host_addr ()); #else throw ::CORBA::NO_IMPLEMENT (); #endif }
/*virtual*/ int BufferedSocket::open(void* arg) { if (Base::open(arg) == -1) return -1; ACE_INET_Addr addr; if (peer().get_remote_addr(addr) == -1) return -1; // <anti DDoS> by boxa uint32 uintAddr = addr.get_ip_address(); if (!uintAddr) return -1; time_t currTime = time(NULL); if (!sIpListStorage.empty()) { // first del expired records for (TIpList::iterator itr = sIpListStorage.begin(); itr != sIpListStorage.end();) { if (itr->second < currTime) sIpListStorage.erase(itr++); else ++itr; } // then search current connected ip TIpList::const_iterator itr = sIpListStorage.find(uintAddr); if (itr != sIpListStorage.end()) return -1; } // add new ip addr into ip list sIpListStorage[uintAddr] = currTime; // </anti DDoS> char address[1024]; addr.get_host_addr(address, 1024); this->remote_address_ = address; this->OnAccept(); return 0; }
// 释放相应资源 virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask mask) { ACE_INET_Addr ClientaddrRemote; this->peer().get_remote_addr(ClientaddrRemote); ACE_OS::printf("[CConnectHandler::open] Close from [%s:%d]\n", ClientaddrRemote.get_host_addr(), ClientaddrRemote.get_port_number()); if (mask == ACE_Event_Handler::WRITE_MASK) return 0; mask = ACE_Event_Handler::ALL_EVENTS_MASK | ACE_Event_Handler::DONT_CALL; this->reactor ()->remove_handler (this, mask); this->sock_.close (); delete this; //socket出错时,将自动删除该客户端,释放相应资源 return 0; }
static void SmartHost(YARPString& result) { char buf[256] = "localhost"; result = buf; int r = ACE_OS::hostname(buf,sizeof(buf)); if (r!=-1) { result = buf; ACE_INET_Addr addr; int r = addr.set((short unsigned int)0,(const char *)buf); if (r!=-1) { YARPString outIp = addr.get_host_addr(); if (outIp!=YARPString("127.0.0.1")) { result = outIp; } } } }
int ConnectAcceptor::open2(ACE_INET_Addr& local_addr, ACE_Reactor* reactor, int flags, int backlog) { ACE_TRACE("ACE_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::open"); this->flags_ = flags; this->use_select_ = 1; this->reuse_addr_ = 1; this->peer_acceptor_addr_ = local_addr; //添加记录监听服务器的IP和端口地址 sprintf_safe(m_szListenIP, MAX_BUFF_20, "%s", local_addr.get_host_addr()); m_u4Port = (uint32)local_addr.get_port_number(); if (reactor == 0) { errno = EINVAL; return -1; } // Open the underlying PEER_ACCEPTOR. if (this->peer_acceptor_.open(local_addr, 1, 0, backlog) == -1) { return -1; } // Set the peer acceptor's handle into non-blocking mode. This is a // safe-guard against the race condition that can otherwise occur // between the time when <select> indicates that a passive-mode // socket handle is "ready" and when we call <accept>. During this // interval, the client can shutdown the connection, in which case, // the <accept> call can hang! (void) this->peer_acceptor_.enable(ACE_NONBLOCK); int const result = reactor->register_handler(this, ACE_Event_Handler::ACCEPT_MASK); if (result != -1) { this->reactor(reactor); } else { this->peer_acceptor_.close(); } return result; }
int ACE_FTP_Addr::addr_to_string (ACE_TCHAR *buffer, size_t size, int flags) const { if (size < this->url_size (flags)) return -1; size_t n = ACE_OS::sprintf (buffer, ACE_TEXT ("ftp://")); if (this->user_ != 0) { n += ACE_OS::sprintf (buffer + n, ACE_PRINTF_S, this->user_); } if (this->password_ != 0) { n += ACE_OS::sprintf (buffer + n, ACE_TEXT (":") ACE_PRINTF_S, this->password_); } if (this->user_ != 0) { n += ACE_OS::sprintf (buffer + n, ACE_TEXT ("@")); } if (flags == 0) { ACE_INET_Addr inet = this->get_inet_address (); n += ACE_OS::sprintf (buffer + n, ACE_PRINTF_S, inet.get_host_addr ()); } else { n += ACE_OS::sprintf (buffer + n, ACE_PRINTF_S, this->hostname_); } if (this->path_ != 0) { n += ACE_OS::sprintf (buffer + n, ACE_TEXT ("/") ACE_PRINTF_S, this->path_); } return 0; }
void Receiver::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_dgram called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_INET_Addr peerAddr; result.remote_address (peerAddr); ACE_DEBUG ((LM_DEBUG, "%s = %s:%d\n", "peer_address", peerAddr.get_host_addr (), peerAddr.get_port_number ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "flags", result.flags ())); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "act", result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "completion_key", result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); if (result.success () && result.bytes_transferred () != 0) { // loop through our message block and print out the contents for (const ACE_Message_Block* msg = result.message_block (); msg != 0; msg = msg->cont ()) { // use msg->length () to get the number of bytes written to the message // block. ACE_DEBUG ((LM_DEBUG, "Buf=[size=<%d>", msg->length ())); for (u_long i = 0; i < msg->length (); ++i) ACE_DEBUG ((LM_DEBUG, "%c", (msg->rd_ptr ())[i])); ACE_DEBUG ((LM_DEBUG, "]\n")); } } ACE_DEBUG ((LM_DEBUG, "Receiver completed\n")); // No need for this message block anymore. result.message_block ()->release (); // Note that we are done with the test. done++; }
TAO_Trading_Loader::TAO_Trading_Loader (void) : federate_ (0), ior_output_file_ (0), bootstrapper_ (0) { char *trader_name = CORBA::string_alloc (MAXHOSTNAMELEN + 10); if (trader_name != 0) { // The trader name is the concatenation of the local host name // and the server's process id. char host_name[MAXHOSTNAMELEN + 1]; ACE_INET_Addr localhost ((u_short) 0); if (localhost.get_host_name (host_name, sizeof (host_name)) != 0) { const char *tmp = localhost.get_host_addr (); if (tmp == 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\nTAO Trading Service (%P|%t) ") ACE_TEXT ("TAO_Trading_Loader ") ACE_TEXT ("- %p\n\n"), ACE_TEXT ("cannot determine hostname"))); else ACE_OS::strcpy (host_name, tmp); } ACE_OS::sprintf (trader_name, "%s_%ld", host_name, static_cast<long> (ACE_OS::getpid ())); for (char *dot = 0; (dot = ACE_OS::strchr (trader_name, '.')) != 0; *dot = '_') continue; ORBSVCS_DEBUG ((LM_DEBUG, "*** Trading Service %C initializing.\n", trader_name)); this->name_ = trader_name; } }