本文整理汇总了C++中ACE_INET_Addr::addr_to_string方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr::addr_to_string方法的具体用法?C++ ACE_INET_Addr::addr_to_string怎么用?C++ ACE_INET_Addr::addr_to_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_INET_Addr
的用法示例。
在下文中一共展示了ACE_INET_Addr::addr_to_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int
Peer_Factory::info (ACE_TCHAR **strp, size_t length) const
{
ACE_TCHAR buf[BUFSIZ];
ACE_TCHAR consumer_addr_str[BUFSIZ];
ACE_TCHAR supplier_addr_str[BUFSIZ];
ACE_INET_Addr addr;
if (this->consumer_acceptor_.acceptor ().get_local_addr (addr) == -1)
return -1;
else if (addr.addr_to_string (consumer_addr_str,
sizeof addr) == -1)
return -1;
else if (this->supplier_acceptor_.acceptor ().get_local_addr (addr) == -1)
return -1;
else if (addr.addr_to_string (supplier_addr_str,
sizeof addr) == -1)
return -1;
ACE_OS::strcpy (buf, ACE_TEXT ("peerd\t C:"));
ACE_OS::strcat (buf, consumer_addr_str);
ACE_OS::strcat (buf, ACE_TEXT ("|S:"));
ACE_OS::strcat (buf, supplier_addr_str);
ACE_OS::strcat
(buf, ACE_TEXT ("/tcp # Gateway traffic generator and data sink\n"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
else
ACE_OS::strncpy (*strp, buf, length);
return ACE_OS::strlen (buf);
}
示例2:
int
Connection_Handler::open (void*)
{
if (this->box_ != 0)
{
ACE_INET_Addr from;
this->peer ().get_remote_addr (from);
const int bufsiz = 128;
char buf[bufsiz];
from.addr_to_string (buf, bufsiz, 0);
static char msg[256];
ACE_OS::sprintf (msg, "connection from <%s>\n", buf);
this->box_->label (msg);
this->box_->redraw ();
}
if (this->w_ != 0)
{
this->w_->incr_sides ();
}
return this->peer ().enable (ACE_NONBLOCK);
}
示例3:
// Open a RAPI QoS session [dest IP, dest port, Protocol ID].
int
ACE_RAPI_Session::open (ACE_INET_Addr dest_addr,
ACE_Protocol_ID protocol_id)
{
char buf [BUFSIZ];
dest_addr.addr_to_string (buf,
BUFSIZ);
ACELIB_DEBUG ((LM_DEBUG,
"In RAPI SESSION OPEN %s\n",
buf));
this->dest_addr_ = dest_addr;
this->protocol_id_ = protocol_id;
// Open a RAPI session. Note "this" is being passed as an argument to
// the callback function. The callback function uses this argument to
// update the QoS of this session based on the RSVP event it receives.
if ((this->session_id_ = rapi_session((struct sockaddr *) dest_addr.get_addr (),
protocol_id,
0,
rsvp_callback,
(void *) this,
&rsvp_error)) == NULL_SID)
ACELIB_ERROR_RETURN ((LM_ERROR,
"rapi_session () call fails. Error\n"),
-1);
else
ACELIB_DEBUG ((LM_DEBUG,
"rapi_session () call succeeds. "
"Session ID = %d\n",
this->session_id_));
return 0;
}
示例4:
ssize_t
RtpsUdpSendStrategy::send_single_i(const iovec iov[], int n,
const ACE_INET_Addr& addr)
{
#ifdef ACE_HAS_IPV6
ACE_SOCK_Dgram& sock = link_->socket_for(addr.get_type());
#define USE_SOCKET sock
#else
#define USE_SOCKET link_->unicast_socket()
#endif
#ifdef ACE_LACKS_SENDMSG
char buffer[UDP_MAX_MESSAGE_SIZE];
char *iter = buffer;
for (int i = 0; i < n; ++i) {
if (iter - buffer + iov[i].iov_len > UDP_MAX_MESSAGE_SIZE) {
ACE_ERROR((LM_ERROR, "(%P|%t) RtpsUdpSendStrategy::send_single_i() - "
"message too large at index %d size %d\n", i, iov[i].iov_len));
return -1;
}
std::memcpy(iter, iov[i].iov_base, iov[i].iov_len);
iter += iov[i].iov_len;
}
const ssize_t result = USE_SOCKET.send(buffer, iter - buffer, addr);
#else
const ssize_t result = USE_SOCKET.send(iov, n, addr);
#endif
if (result < 0) {
ACE_TCHAR addr_buff[256] = {};
addr.addr_to_string(addr_buff, 256, 0);
ACE_ERROR((LM_ERROR, "(%P|%t) RtpsUdpSendStrategy::send_single_i() - "
"destination %s failed %p\n", addr_buff, ACE_TEXT("send")));
}
return result;
}
示例5: run_main
int run_main (int argc, ACE_TCHAR *argv[])
{
ACE_START_TEST (ACE_TEXT ("FlReactor_Test"));
Fl_Window window (300, 370);
Test_Window tw (10, 75, window.w () - 20, window.h ()-90);
window.resizable (&tw);
Fl_Hor_Slider slider (60, 5, window.w () - 70, 30, "Sides:");
slider.align (FL_ALIGN_LEFT);
slider.callback (sides_cb, &tw);
slider.value (tw.sides ());
slider.step (1);
slider.bounds (3, 10);
ACE_FlReactor reactor;
ACE_Reactor r (&reactor);
Fl_Box *box = new Fl_Box (FL_UP_BOX, 10, 40,
window.w () - 20, 30,
"Setting up");
box->labelfont (FL_BOLD);
Acceptor acceptor (&tw, box);
ACE_INET_Addr address;
if (acceptor.open (address, &r) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"open acceptor"),
-1);
acceptor.acceptor ().get_local_addr (address);
const int bufsiz = 128;
char buf[bufsiz];
address.addr_to_string (buf, bufsiz, 0);
char msg[2 * bufsiz];
ACE_OS::sprintf (msg, "Listening on <%s>\n", buf);
box->label (msg);
box->redraw ();
window.end ();
window.show (argc, argv);
tw.show ();
return Fl::run ();
ACE_END_TEST;
}
示例6:
void
PSession::addresses (const ACE_INET_Addr& peer, const ACE_INET_Addr& local)
{
ACE_TCHAR str_peer [256];
ACE_TCHAR str_local[256];
if (0 != peer.addr_to_string (str_peer, sizeof (str_peer)/sizeof (ACE_TCHAR)))
ACE_OS::strcpy (str_peer, ACE_TEXT("????"));
if (0 != local.addr_to_string (str_local, sizeof (str_local)/sizeof (ACE_TCHAR)))
ACE_OS::strcpy (str_peer, ACE_TEXT("????"));
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%t) %s=%d Remote=%s Local=%s\n"),
this->get_name(),
this->index(),
str_peer,
str_local));
return;
}
示例7: open
// Registers the new ClientService instance with the reactor
//
// We try to print a log message stating which host connected, then call ACE_Reactor::register_handler()
// to register for input events with the reactor. We return the return value of register_handler(),
// which is 0 for success and �for failure. This value is passed back to the ClientAcceptor::handle_input() method,
// and handle_input() also will return �for error and 0 for success.
// If ClientAcceptor::handle_input() returns �we will have to close the handle.
//
int ClientService::open()
{
ACE_TCHAR peerName[MAXHOSTNAMELEN];
ACE_INET_Addr peerAddress;
if (this->m_socket.get_remote_addr(peerAddress) == 0 && peerAddress.addr_to_string(peerName, MAXHOSTNAMELEN) == 0)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Connection from %s\n"), peerName));
}
return this->reactor()->register_handler(this, ACE_Event_Handler::READ_MASK);
}
示例8: defined
int
TAO_AV_TCP_Flow_Handler::open (void * /*arg*/)
{
#if defined (TCP_NODELAY)
int nodelay = 1;
if (this->peer ().set_option (IPPROTO_TCP,
TCP_NODELAY,
(void *) &nodelay,
sizeof (nodelay)) == -1)
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"NODELAY failed\n"),
-1);
#endif /* TCP_NODELAY */
int buf_size = BUFSIZ;
int s = sizeof (buf_size);
if (this->peer ().get_option (SOL_SOCKET, /*IPPROTO_TCP,*/
SO_RCVBUF,
(void *) &buf_size, &s) == -1)
buf_size = BUFSIZ;
((TAO_AV_TCP_Object*)(this->protocol_object_))->frame_.size (buf_size);
// Called by the <Strategy_Acceptor> when the handler is completely
// connected.
ACE_INET_Addr addr;
if (this->peer ().get_remote_addr (addr) == -1)
return -1;
ACE_TCHAR server[MAXHOSTNAMELEN + 16];
(void) addr.addr_to_string (server, sizeof (server));
if (TAO_debug_level > 0)
if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,
"(%P|%t) connection to server <%s> on %d\n",
server, this->peer ().get_handle ()));
this->peer ().enable (ACE_NONBLOCK);
// Register the handler with the reactor.
if (this->reactor ()
&& this->reactor ()->register_handler
(this,
ACE_Event_Handler::READ_MASK) == -1)
ORBSVCS_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("unable to register client handler")),
-1);
return 0;
}
示例9: client_addr
string chromatic_handler::client_addr()
{
ACE_INET_Addr addr;
char addrstr[MAXHOSTNAMELEN + 1];
peer().get_remote_addr( addr );
addr.addr_to_string( addrstr , sizeof( addrstr ) );
string strTemp( addrstr );
return ( strTemp );
}
示例10: addr_to_string
static void addr_to_string (const ACE_INET_Addr &ip_addr,
ACE_TCHAR *ret_string, // results here.
size_t len,
int clip_portnum) // clip port# info?
{
if (ip_addr.addr_to_string (ret_string, len, 1) == -1)
ACE_OS::strcpy (ret_string, ACE_TEXT ("<?>"));
else
{
ACE_TCHAR *pc = ACE_OS::strrchr (ret_string, ACE_TEXT (':'));
if (clip_portnum && pc)
*pc = ACE_TEXT ('\0'); // clip port# info.
}
}
示例11:
int
TAO_AV_SCTP_SEQ_Acceptor::open_default (TAO_Base_StreamEndPoint *endpoint,
TAO_AV_Core *av_core,
TAO_FlowSpec_Entry *entry,
TAO_AV_Flow_Protocol_Factory *factory,
TAO_AV_Core::Flow_Component flow_comp)
{
this->flow_protocol_factory_ = factory;
this->av_core_ = av_core;
this->endpoint_ = endpoint;
this->entry_ = entry;
if (flow_comp == TAO_AV_Core::TAO_AV_CONTROL)
this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname());
else
this->flowname_ = entry->flowname ();
ACE_INET_Addr *address;
ACE_NEW_RETURN (address,
ACE_INET_Addr ("0"),
-1);
int result = this->acceptor_.acceptor_open (this,
av_core->reactor (),
*address,
entry);
if (result < 0)
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"TAO_AV_SCTP_SEQ_Acceptor::open failed"),
-1);
this->acceptor_.acceptor ().get_local_addr (*address);
address->set (address->get_port_number (),
address->get_host_name ());
char buf[BUFSIZ];
address->addr_to_string (buf,BUFSIZ);
if (TAO_debug_level > 0)
ORBSVCS_DEBUG ((LM_DEBUG,
"TAO_AV_SCTP_SEQ_Acceptor::open_default: %s\n",
buf));
entry->set_local_addr (address);
return 0;
}
示例12: test_multiple
static bool test_multiple (void)
{
bool success = true;
// Check the behavior when there are multiple addresses assigned to a name.
// The NTP pool should always return multiples, though always different.
ACE_INET_Addr ntp;
if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1)
{
// This is just a warning to prevent fails on lookups on hosts with no
// DNS service. The real value of this test is to accurately get
// multiples from the result.
ACE_ERROR ((LM_WARNING, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org")));
return true;
}
size_t count = 0;
ACE_TCHAR addr_string[256];
do
{
++count; // If lookup succeeded, there's at least one
ntp.addr_to_string (addr_string, sizeof (addr_string));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string));
}
while (ntp.next ());
success = count > 1;
#if defined (ACE_HAS_IPV6)
ACE_INET_Addr ntp6;
if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org")));
return false;
}
count = 0;
do
{
++count; // If lookup succeeded, there's at least one
ntp6.addr_to_string (addr_string, sizeof (addr_string));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string));
}
while (ntp6.next ());
if (count <= 1)
success = false;
#endif /* ACE_HAS_IPV6 */
return success;
}
示例13: local
int
ACE_TMAIN (int argc, ACE_TCHAR * argv[])
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Server: ")
ACE_TEXT ("At start of main\n")));
ACE_OS::socket_init (ACE_WSOCK_VERSION);
if (parse_args (argc, argv) != 0)
return 1;
ACE_TCHAR host[MAXHOSTNAMELEN+1];
if (ACE_OS::hostname (host, MAXHOSTNAMELEN) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) Server failure: %p\n"),
ACE_TEXT ("hostname")),
1);
ACE_INET_Addr local (port, host);
local.addr_to_string (host, MAXHOSTNAMELEN);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Server: ")
ACE_TEXT ("listening at %s\n"),
host));
ACE_SOCK_Acceptor acc (local, 1);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Server: ")
ACE_TEXT ("opened listener\n")));
Accept_Handler handler (acc);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Server: ")
ACE_TEXT ("server is ready\n")));
if (notifier_file != 0)
{
FILE *f = ACE_OS::fopen (notifier_file,ACE_TEXT("w+"));
const char *msg = "server ready";
ACE_OS::fwrite (msg,ACE_OS::strlen(msg),1,f);
ACE_OS::fclose (f);
}
ACE_Reactor::instance()->run_reactor_event_loop();
return 0;
}
示例14: UpdateRealm
void RealmList::UpdateRealm(uint32 ID, const std::string& name, ACE_INET_Addr const& address, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build)
{
// Create new if not exist or update existed
Realm& realm = m_realms[name];
realm.m_ID = ID;
realm.name = name;
realm.icon = icon;
realm.flag = flag;
realm.timezone = timezone;
realm.allowedSecurityLevel = allowedSecurityLevel;
realm.populationLevel = popu;
// Append port to IP address.
address.addr_to_string(realm.address, ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16);
realm.gamebuild = build;
}
示例15: RPG_TRACE
void
RPG_Net_Client_AsynchConnector::connect(const ACE_INET_Addr& peer_address)
{
RPG_TRACE(ACE_TEXT("RPG_Net_Client_AsynchConnector::connect"));
int result =
inherited::connect(peer_address, // remote SAP
ACE_sap_any_cast(const ACE_INET_Addr&), // local SAP
1, // re-use address (SO_REUSEADDR) ?
NULL); // ACT
if (result == -1)
{
ACE_TCHAR buffer[RPG_COMMON_BUFSIZE];
ACE_OS::memset(buffer, 0, sizeof(buffer));
if (peer_address.addr_to_string(buffer,
sizeof(buffer)) == -1)
ACE_DEBUG((LM_ERROR,
ACE_TEXT("failed to ACE_INET_Addr::addr_to_string(): \"%m\", continuing\n")));
ACE_DEBUG((LM_ERROR,
ACE_TEXT("failed to ACE_Asynch_Connector::connect(\"%s\"): \"%m\", aborting\n"),
buffer));
} // end IF
}