本文整理汇总了C++中ACE_TLI_Stream::open方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_TLI_Stream::open方法的具体用法?C++ ACE_TLI_Stream::open怎么用?C++ ACE_TLI_Stream::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_TLI_Stream
的用法示例。
在下文中一共展示了ACE_TLI_Stream::open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int
ACE_TLI_Connector::connect (ACE_TLI_Stream &new_stream,
const ACE_Addr &remote_sap,
ACE_Time_Value *timeout,
const ACE_Addr &local_sap,
int reuse_addr,
int flags,
int /* perms */,
const char device[],
struct t_info *info,
int rwf,
struct netbuf *udata,
struct netbuf *opt)
{
ACE_TRACE ("ACE_TLI_Connector::connect");
int result = 0;
// Only open a new endpoint if we don't already have a valid handle.
if (new_stream.get_handle () == ACE_INVALID_HANDLE
&& new_stream.open (device, flags, info) == ACE_INVALID_HANDLE)
return -1;
if (local_sap != ACE_Addr::sap_any)
{
// Bind the local endpoint to a specific addr.
struct t_bind *localaddr;
localaddr = (struct t_bind *)
ACE_OS::t_alloc (new_stream.get_handle (), T_BIND, T_ADDR);
if (localaddr == 0)
result = -1;
else
{
int one = 1;
#if !defined (ACE_HAS_FORE_ATM_XTI)
// Reusing the address causes problems with FORE's API. The
// issue may be that t_optmgmt isn't fully supported by
// FORE. t_errno is TBADOPT after the t_optmgmt call so
// maybe options are configured differently for XTI than for
// TLI (at least for FORE's implementation - XTI is supposed
// to be a superset of TLI).
if (reuse_addr
&& new_stream.set_option (SOL_SOCKET,
SO_REUSEADDR,
&one,
sizeof one) == -1)
result = -1;
else
#endif /* ACE_HAS_FORE_ATM_XTI */
{
void *addr_buf = local_sap.get_addr ();
localaddr->addr.len = local_sap.get_size ();
ACE_OS::memcpy(localaddr->addr.buf,
addr_buf,
localaddr->addr.len);
if (ACE_OS::t_bind (new_stream.get_handle (),
localaddr,
localaddr) == -1)
result = -1;
ACE_OS::t_free ((char *) localaddr,
T_BIND);
}
}
if (result == -1)
{
new_stream.close ();
return -1;
}
}
// Let TLI select the local endpoint addr.
else if (ACE_OS::t_bind (new_stream.get_handle (), 0, 0) == -1)
return -1;
struct t_call *callptr = 0;
callptr = (struct t_call *)
ACE_OS::t_alloc (new_stream.get_handle (), T_CALL, T_ADDR);
if (callptr == 0)
{
new_stream.close ();
return -1;
}
void *addr_buf = remote_sap.get_addr ();
callptr->addr.len = remote_sap.get_size ();
ACE_OS::memcpy (callptr->addr.buf,
addr_buf,
callptr->addr.len);
//callptr->addr.buf = (char *) remote_sap.get_addr ();
if (udata != 0)
ACE_OS::memcpy ((void *) &callptr->udata, (void *) udata, sizeof *udata);
if (opt != 0)
//.........这里部分代码省略.........