ACE学习之ACE_INET_Addr,ACE_SOCK_Acceptor 源代码

ACE_INET_Addr地址类浅解析 说起网络编程,第一个我们必须想到的就是socket等系类函数,而这些函数的调用中有一个十分重要的参数sockaddr_in这个Ipv4的结构体,这个结构体表示了网络地址,即通信地址,但是玩过它的人都知道,大量的细节我们必须注意,包括初始化,转变字节序等等的一系列的重复的动作很是令人厌烦。 但在ACE中,这些细节ACE_INET_Addr都帮你做了,使用起来很方便,而且不用担心安全问题,那么这里就解 阅读详情

ACE_INET_Addr 用来封装了基本的LINUX Socket的连接。

 

首先了解一个结构体

 struct sockaddr_in
  {
    short            sin_family;   // e.g. AF_INET
    unsigned short   sin_port;     // e.g. htons(3490)
    struct in_addr   sin_addr;     // see struct in_addr, below
    char             sin_zero[8];  // zero this if you want to
  };


看到了这个结构体,应该熟悉到最基础的linux socket编程,就是要用到这些数据。。。

 

/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    INET_Addr.h
 *
 *  $Id: INET_Addr.h 91626 2010-09-07 10:59:20Z johnnyw $
 *
 *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
 */
//=============================================================================

#ifndef ACE_INET_ADDR_H
#define ACE_INET_ADDR_H
#include /**/ "ace/pre.h"

#include "ace/Sock_Connect.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Addr.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class ACE_INET_Addr
 *
 * @brief Defines a C++ wrapper facade for the Internet domain address
 * family format.
 */
class ACE_Export ACE_INET_Addr : public ACE_Addr
{
public:
  // = Initialization methods.

  /// Default constructor.
  ACE_INET_Addr (void);

  /// Copy constructor.
  ACE_INET_Addr (const ACE_INET_Addr &);

  /// Creates an ACE_INET_Addr from a sockaddr_in structure.
  ACE_INET_Addr (const sockaddr_in *addr, int len);

  /// Creates an ACE_INET_Addr from a @a port_number and the remote
  /// @a host_name. The port number is assumed to be in host byte order.
  /// To set a port already in network byte order, please @see set().
  /// Use address_family to select IPv6 (PF_INET6) vs. IPv4 (PF_INET).
  ACE_INET_Addr (u_short port_number,
                 const char host_name[],
                 int address_family = AF_UNSPEC);

  /**
   * Initializes an ACE_INET_Addr from the @a address, which can be
   * "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or
   * "128.252.166.57:1234").  If there is no ':' in the @a address it
   * is assumed to be a port number, with the IP address being
   * INADDR_ANY.
   */
  explicit ACE_INET_Addr (const char address[],
                          int address_family = AF_UNSPEC);

  /**
   * Creates an ACE_INET_Addr from a @a port_number and an Internet
   * @a ip_addr.  This method assumes that @a port_number and @a ip_addr
   * are in host byte order. If you have addressing information in
   * network byte order, @see set().
   */
  explicit ACE_INET_Addr (u_short port_number,
                          ACE_UINT32 ip_addr = INADDR_ANY);

  /// Uses getservbyname() to create an ACE_INET_Addr from a
  /// @a port_name, the remote @a host_name, and the @a protocol.
  ACE_INET_Addr (const char port_name[],
                 const char host_name[],
                 const char protocol[] = "tcp");

  /**
   * Uses getservbyname() to create an ACE_INET_Addr from a
   * @a port_name, an Internet @a ip_addr, and the @a protocol.  This
   * method assumes that @a ip_addr is in host byte order.
   */
  ACE_INET_Addr (const char port_name[],
                 ACE_UINT32 ip_addr,
                 const char protocol[] = "tcp");

#if defined (ACE_HAS_WCHAR)
  ACE_INET_Addr (u_short port_number,
                 const wchar_t host_name[],
                 int address_family = AF_UNSPEC);

  explicit ACE_INET_Addr (const wchar_t address[],
                          int address_family = AF_UNSPEC);

  ACE_INET_Addr (const wchar_t port_name[],
                 const wchar_t host_name[],
                 const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));

  ACE_INET_Addr (const wchar_t port_name[],
                 ACE_UINT32 ip_addr,
                 const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));
#endif /* ACE_HAS_WCHAR */

  /// Default dtor.
  ~ACE_INET_Addr (void);

  // = Direct initialization methods.

  // These methods are useful after the object has been constructed.

  /// Initializes from another ACE_INET_Addr.
  int set (const ACE_INET_Addr &);

  /**
   * Initializes an ACE_INET_Addr from a @a port_number and the
   * remote @a host_name.  If @a encode is non-zero then @a port_number is
   * converted into network byte order, otherwise it is assumed to be
   * in network byte order already and are passed straight through.
   * address_family can be used to select IPv4/IPv6 if the OS has
   * IPv6 capability (ACE_HAS_IPV6 is defined). To specify IPv6, use
   * the value AF_INET6. To specify IPv4, use AF_INET.
   */
  int set (u_short port_number,
           const char host_name[],
           int encode = 1,
           int address_family = AF_UNSPEC);

  /**
   * Initializes an ACE_INET_Addr from a @a port_number and an Internet
   * @a ip_addr.  If @a encode is non-zero then the port number and IP address
   * are converted into network byte order, otherwise they are assumed to be
   * in network byte order already and are passed straight through.
   *
   * If @a map is non-zero and IPv6 support has been compiled in,
   * then this address will be set to the IPv4-mapped IPv6 address of it.
   */
  int set (u_short port_number,
           ACE_UINT32 ip_addr = INADDR_ANY,
           int encode = 1,
           int map = 0);

  /// Uses getservbyname() to initialize an ACE_INET_Addr from a
  /// @a port_name, the remote @a host_name, and the @a protocol.
  int set (const char port_name[],
           const char host_name[],
           const char protocol[] = "tcp");

  /**
   * Uses getservbyname() to initialize an ACE_INET_Addr from a
   * @a port_name, an @a ip_addr, and the @a protocol.  This assumes that
   * @a ip_addr is already in network byte order.
   */
  int set (const char port_name[],
           ACE_UINT32 ip_addr,
           const char protocol[] = "tcp");

  /**
   * Initializes an ACE_INET_Addr from the @a addr, which can be
   * "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or
   * "128.252.166.57:1234").  If there is no ':' in the @a address it
   * is assumed to be a port number, with the IP address being
   * INADDR_ANY.
   */
  int set (const char addr[], int address_family = AF_UNSPEC);

  /// Creates an ACE_INET_Addr from a sockaddr_in structure.
  int set (const sockaddr_in *,
           int len);

#if defined (ACE_HAS_WCHAR)
  int set (u_short port_number,
           const wchar_t host_name[],
           int encode = 1,
           int address_family = AF_UNSPEC);

  int set (const wchar_t port_name[],
           const wchar_t host_name[],
           const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));

  int set (const wchar_t port_name[],
           ACE_UINT32 ip_addr,
           const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));

  int set (const wchar_t addr[], int address_family = AF_UNSPEC);
#endif /* ACE_HAS_WCHAR */

  /// Return a pointer to the underlying network address.
  virtual void *get_addr (void) const;
  int get_addr_size(void) const;

  /// Set a pointer to the address.
  virtual void set_addr (void *, int len);

  /// Set a pointer to the address.
  virtual void set_addr (void *, int len, int map);

  /**
   * Transform the current ACE_INET_Addr address into string format.
   * If @a ipaddr_format is ttrue this produces "ip-number:port-number"
   * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false
   * this produces "ip-name:port-number" (e.g.,
   * "tango.cs.wustl.edu:1234").  Returns -1 if the @a size of the
   * @a buffer is too small, else 0.
   */
  virtual int addr_to_string (ACE_TCHAR buffer[],
                              size_t size,
                              int ipaddr_format = 1) const;

  /**
   * Initializes an ACE_INET_Addr from the @a address, which can be
   * "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"),
   * "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"),
   * "ip-number:port-number" (e.g., "128.252.166.57:1234"), or
   * "ip-number:port-name" (e.g., "128.252.166.57:telnet").  If there
   * is no ':' in the @a address it is assumed to be a port number,
   * with the IP address being INADDR_ANY.
   */
  virtual int string_to_addr (const char address[],
                              int address_family = AF_UNSPEC);

#if defined (ACE_HAS_WCHAR)
  /*
  virtual int string_to_addr (const char address[]);
  */
#endif /* ACE_HAS_WCHAR */

  /**
   * Sets the port number without affecting the host name.  If
   * @a encode is enabled then @a port_number is converted into network
   * byte order, otherwise it is assumed to be in network byte order
   * already and are passed straight through.
   */
  void set_port_number (u_short,
                        int encode = 1);

  /**
   * Sets the address without affecting the port number.  If
   * @a encode is enabled then @a ip_addr is converted into network
   * byte order, otherwise it is assumed to be in network byte order
   * already and are passed straight through.  The size of the address
   * is specified in the @a len parameter.
   * If @a map is non-zero, IPv6 support has been compiled in, and
   * @a ip_addr is an IPv4 address, then this address is set to the IPv4-mapped
   * IPv6 address of it.
   */
  int set_address (const char *ip_addr,
                   int len,
                   int encode = 1,
                   int map = 0);

#if (defined (__linux__) || defined (ACE_WIN32)) && defined (ACE_HAS_IPV6)
  /**
   * Sets the interface that should be used for this address. This only has
   * an effect when the address is link local, otherwise it does nothing.
   */
  int set_interface (const char *intf_name);
#endif /* (__linux__ || ACE_WIN32) && ACE_HAS_IPV6 */

  /// Return the port number, converting it into host byte-order.
  u_short get_port_number (void) const;

  /**
   * Return the character representation of the name of the host,
   * storing it in the @a hostname (which is assumed to be
   * @a hostnamelen bytes long).  This version is reentrant.  If
   * @a hostnamelen is greater than 0 then @a hostname will be
   * NUL-terminated even if -1 is returned.
   */
  int get_host_name (char hostname[],
                     size_t hostnamelen) const;

#if defined (ACE_HAS_WCHAR)
  int get_host_name (wchar_t hostname[],
                     size_t hostnamelen) const;
#endif /* ACE_HAS_WCHAR */

  /**
   * Return the character representation of the hostname.  This
   * version is non-reentrant since it returns a pointer to a static
   * data area.  You should therefore either (1) do a "deep copy" of
   * the address returned by get_host_name(), e.g., using strdup() or
   * (2) use the "reentrant" version of get_host_name() described
   * above.
   */
  const char *get_host_name (void) const;

  /**
   * Return the "dotted decimal" Internet address representation of
   * the hostname storing it in the @a addr (which is assumed to be
   * @a addr_size bytes long).  This version is reentrant.
   */
  const char *get_host_addr (char *addr, int addr_size) const;

  /**
   * Return the "dotted decimal" Internet address representation of
   * the hostname.  This version is non-reentrant since it returns a
   * pointer to a static data area.  You should therefore either
   * (1) do a "deep copy" of the address returned by get_host_addr(), e.g.,
   * using strdup() or (2) use the "reentrant" version of
   * get_host_addr() described above.
   */
  const char *get_host_addr (void) const;

  /// Return the 4-byte IP address, converting it into host byte
  /// order.
  ACE_UINT32 get_ip_address (void) const;

  /// Return @c true if the IP address is INADDR_ANY or IN6ADDR_ANY.
  bool is_any (void) const;

  /// Return @c true if the IP address is IPv4/IPv6 loopback address.
  bool is_loopback (void) const;

  /// Return @c true if the IP address is IPv4/IPv6 multicast address.
  bool is_multicast (void) const;

#if defined (ACE_HAS_IPV6)
  /// Return @c true if the IP address is IPv6 linklocal address.
  bool is_linklocal (void) const;

  /// Return @c true if the IP address is IPv4-mapped IPv6 address.
  bool is_ipv4_mapped_ipv6 (void) const;

  /// Return @c true if the IP address is IPv4-compatible IPv6 address.
  bool is_ipv4_compat_ipv6 (void) const;
#endif /* ACE_HAS_IPV6 */

  /**
   * Returns @c true if @c this is less than @a rhs.  In this context,
   * "less than" is defined in terms of IP address and TCP port
   * number.  This operator makes it possible to use @c ACE_INET_Addrs
   * in STL maps.
   */
  bool operator < (const ACE_INET_Addr &rhs) const;

  /// Compare two addresses for equality.  The addresses are considered
  /// equal if they contain the same IP address and port number.
  bool operator == (const ACE_INET_Addr &SAP) const;

  /// Compare two addresses for inequality.
  bool operator != (const ACE_INET_Addr &SAP) const;

  /// A variation of the equality operator, this method only compares the
  /// IP address and ignores the port number.
  bool is_ip_equal (const ACE_INET_Addr &SAP) const;

  /// Computes and returns hash value.
  virtual u_long hash (void) const;

  /// Dump the state of an object.
  void dump (void) const;

  /// Declare the dynamic allocation hooks.
  ACE_ALLOC_HOOK_DECLARE;

private:
  /// Insure that @a hostname is properly null-terminated.
  int get_host_name_i (char hostname[], size_t hostnamelen) const;

  // Methods to gain access to the actual address of
  // the underlying internet address structure.
  void *ip_addr_pointer (void) const;
  int ip_addr_size (void) const;
  int determine_type (void) const;

  /// Initialize underlying inet_addr_ to default values
  void reset (void);

  /// Underlying representation.
  /// This union uses the knowledge that the two structures share the
  /// first member, sa_family (as all sockaddr structures do).
  union
  {
    sockaddr_in  in4_;
#if defined (ACE_HAS_IPV6)
    sockaddr_in6 in6_;
#endif /* ACE_HAS_IPV6 */
  } inet_addr_;
};

ACE_END_VERSIONED_NAMESPACE_DECL

#if defined (__ACE_INLINE__)
#include "ace/INET_Addr.inl"
#endif /* __ACE_INLINE__ */

#include /**/ "ace/post.h"
#endif /* ACE_INET_ADDR_H */

 

首先,我们可以看到,该类对网络地址和端口号进行了封装。尤其是对tcp下的IPV4和IPV6.进行了完美的封装。

如何使用呢?

 ACE_SOCK_Acceptor  m_acceptorSocket;

 ACE_INET_Addr  acceptorAddr;    
 acceptorAddr.set(atoi(port));
m_acceptorSocket.open(acceptorAddr, 1);

这样就建立了一个侦听的端口,等待客户端进行请求连接。下面就介绍一下ACE_SOCK_Acceptor

ACE_SOCK_Acceptor

ACE_SOCK_Acceptor 该类封装了acceptor,一种被动客户连接的一个类。学过底层应该都知道。。

/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    SOCK_Acceptor.h
 *
 *  $Id: SOCK_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $
 *
 *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
 */
//=============================================================================

#ifndef ACE_SOCK_ACCEPTOR_H
#define ACE_SOCK_ACCEPTOR_H
#include /**/ "ace/pre.h"

#include "ace/SOCK_Stream.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

class ACE_Time_Value;
class ACE_Accept_QoS_Params;

/**
 * @class ACE_SOCK_Acceptor
 *
 * @brief Defines a factory that creates new ACE_Streams passively.
 *
 * The ACE_SOCK_Acceptor has its own "passive-mode" socket.
 * This serves as a factory to create so-called "data-mode"
 * sockets, which are what the ACE_SOCK_Stream encapsulates.
 * Therefore, by inheriting from ACE_SOCK, ACE_SOCK_Acceptor
 * gets its very own socket.
 */
class ACE_Export ACE_SOCK_Acceptor : public ACE_SOCK
{
public:
  // = Initialization and termination methods.
  /// Default constructor.
  ACE_SOCK_Acceptor (void);

  /**
   * Initialize a passive-mode BSD-style acceptor socket (no QoS).
   * @a local_sap is the address that we're going to listen for
   * connections on.  If @a reuse_addr is 1 then we'll use the
   * @c SO_REUSEADDR to reuse this address.
   */
  ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
                     int reuse_addr = 0,
                     int protocol_family = PF_UNSPEC,
                     int backlog = ACE_DEFAULT_BACKLOG,
                     int protocol = 0);

  /// Initialize a passive-mode QoS-enabled acceptor socket.  Returns 0
  /// on success and -1 on failure.
  ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
                     ACE_Protocol_Info *protocolinfo,
                     ACE_SOCK_GROUP g,
                     u_long flags,
                     int reuse_addr,
                     int protocol_family = PF_UNSPEC,
                     int backlog = ACE_DEFAULT_BACKLOG,
                     int protocol = 0);

  /**
   * Initialize a passive-mode BSD-style acceptor socket (no QoS).
   * @a local_sap is the address that we're going to listen for
   * connections on.  If @a reuse_addr is 1 then we'll use the
   * @c SO_REUSEADDR to reuse this address.  Returns 0 on success and
   * -1 on failure.
   */
  int open (const ACE_Addr &local_sap,
            int reuse_addr = 0,
            int protocol_family = PF_UNSPEC,
            int backlog = ACE_DEFAULT_BACKLOG,
            int protocol = 0);

  /// Initialize a passive-mode QoS-enabled acceptor socket.  Returns 0
  /// on success and -1 on failure.
  int open (const ACE_Addr &local_sap,
            ACE_Protocol_Info *protocolinfo,
            ACE_SOCK_GROUP g,
            u_long flags,
            int reuse_addr,
            int protocol_family = PF_UNSPEC,
            int backlog = ACE_DEFAULT_BACKLOG,
            int protocol = 0);

  /// Close the socket.  Returns 0 on success and -1 on failure.
  int close (void);

  /// Default dtor.
  ~ACE_SOCK_Acceptor (void);

  // = Passive connection <accept> methods.
  /**
   * Accept a new ACE_SOCK_Stream connection.  A @a timeout of 0
   * means block forever, a @a timeout of {0, 0} means poll.  @a restart
   * == true means "restart if interrupted," i.e., if errno == EINTR.
   * Note that @a new_stream inherits the "blocking mode" of @c this
   * ACE_SOCK_Acceptor, i.e., if @c this acceptor factory is in
   * non-blocking mode, the @a new_stream will be in non-blocking mode
   * and vice versa.
   */
  int accept (ACE_SOCK_Stream &new_stream,
              ACE_Addr *remote_addr = 0,
              ACE_Time_Value *timeout = 0,
              bool restart = true,
              bool reset_new_handle = false) const;

#if !defined (ACE_HAS_WINCE)
  /**
   * Accept a new ACE_SOCK_Stream connection using the QoS
   * information in @a qos_params.  A @a timeout of 0 means block
   * forever, a @a timeout of {0, 0} means poll.  @a restart == true means
   * "restart if interrupted," i.e., if errno == EINTR.  Note that
   * @a new_stream inherits the "blocking mode" of @c this
   * ACE_SOCK_Acceptor, i.e., if @c this acceptor factory is in
   * non-blocking mode, the @a new_stream will be in non-blocking mode
   * and vice versa.
   */
  int accept (ACE_SOCK_Stream &new_stream,
              ACE_Accept_QoS_Params qos_params,
              ACE_Addr *remote_addr = 0,
              ACE_Time_Value *timeout = 0,
              bool restart = true,
              bool reset_new_handle = false) const;
#endif  // ACE_HAS_WINCE

  // = Meta-type info
  typedef ACE_INET_Addr PEER_ADDR;
  typedef ACE_SOCK_Stream PEER_STREAM;

  /// Dump the state of an object.
  void dump (void) const;

  /// Declare the dynamic allocation hooks.
  ACE_ALLOC_HOOK_DECLARE;

protected:
  /// Perform operations that must occur before <ACE_OS::accept> is
  /// called.
  int shared_accept_start (ACE_Time_Value *timeout,
                           bool restart,
                           int &in_blocking_mode) const;

  /// Perform operations that must occur after <ACE_OS::accept> is
  /// called.
  int shared_accept_finish (ACE_SOCK_Stream new_stream,
                            int in_blocking_mode,
                            bool reset_new_handle) const;

  /**
   * This method factors out the common <open> code and is called by
   * both the QoS-enabled <open> method and the BSD-style <open>
   * method.
   */
  int shared_open (const ACE_Addr &local_sap,
                   int protocol_family,
                   int backlog);

private:
  /// Do not allow this function to percolate up to this interface...
  int get_remote_addr (ACE_Addr &) const;
};

ACE_END_VERSIONED_NAMESPACE_DECL

#if defined (__ACE_INLINE__)
#include "ace/SOCK_Acceptor.inl"
#endif /* __ACE_INLINE__ */

#include /**/ "ace/post.h"
#endif /* ACE_SOCK_ACCEPTOR_H */


 

这个是一种被动模式啊~

ACE的源码划分和library subsetting 前几篇文章也提到过,ACE的所有源文件和头文件都杂乱堆在了ACE_wrappers/ace目录下。这样的代码组织方式给学习ACE带来了很大的困难,很多朋友在看到ace目录下庞大的代码的时候,几乎就失去了学习ACE的信心^_^。因此,我们有必要对ACE的代码进行重新组织,以降低学习曲线。下面,我将给出我对ACE源码的划分方法。其实,我也是刚学习ACE没有多久,对ACE的了解还甚少,所以,我的源码划方 阅读详情

相关推荐

ACE中ACE_SOCK下ACE_SOCK_Acceptor类解析

ACE_SOCK_Acceptor,ACE中面对流(有连接)sock编程的接受器类,将服务器端编程的细节,步骤做了包装,让我们不需要再直接的使用OS的复杂,繁多的API函数,那么这个类中到底替我们做了多少呢?我们该如何修改它呢?首先看类的构造函数:ACE_SOCK_Acceptor (void);ACE_SOCK_Acceptor (const ACE_Addr &local_sap,

FebruarySwallow的博客 1815

【ACE】ACE程序运行时,出现错误 ACE WSA Startup not initialized 的解决

问题1:VS 2005中执行release版本的ACE程序,出现错误:ACE WSA Startup not initialized。 上网查阅资料,发现如下答案: 右键VS 2005工程,属性->配置属性->常规(Gerneral) 字符集(Character Set): Use Unicode Character Set 改为 Character Set:未设置( Not S

风声 2979

OpenHarmony 实战开发——一文总结ACE代码框架

ACE_Engine框架是OpenAtom OpenHarmony(简称“OpenHarmony”)的UI开发框架,为开发者提供在进行应用UI开发时所必需的各种组件,以及定义这些组件的属性、样式、事件及方法,通过这些组件可以方便进行OpenHarmony上UI应用的开发。

鸿蒙开发知识记录 1405

ACE笔记(4) -ACE_Reactor 机制下 的ACE异常处理

 ACE_Manual_Event 类  唤醒所有正在等待的线程,并重新设置信号 常用构造:  ACE_Manual_Event(1) 表当前对象已经准备就绪,一旦有线程处于等待状态,就将触发并重置事件异常处理的语法结构:        ACE_SEH_TRY          {            //可能发生异常的代码          }        ACE_SEH_EXCEPT

942

ACE之socket

ACE_IPC_SAP:提供获取,设置句柄,io控制,以及控制ACE_SIGIO,ACE_SIGURG,ACE_NONBLOCK和ACE_CLOEXEC的开启关闭。ACE_SOCK_Acceptor ,ACE_SOCK_Connector 用于创建不同角色的ACE_SOCK_Stream。ACE_SOCK_Stream:在ACE_SOCK_IO基础上添加了发送,接收的字节数。ACE_SOCK :提供打开,关闭,获取,设置选项以及获取本端以及远端地址。ACE_SOCK_IO :提供发送,接收数据功能。

多看多听多总结 1378

Windows 10/11下彻底卸载Chrome的终极指南(附一键清理注册表脚本)

本文提供了一份在Windows 10/11系统中彻底卸载Google Chrome浏览器的终极指南。针对标准卸载后用户数据与注册表项残留的问题,文章详细介绍了从应用程序层、用户数据层到系统集成层的三层深度清理方法,并重点提供了安全高效的注册表清理脚本,确保浏览器所有痕迹被完全移除,解决重装冲突并释放磁盘空间。

elastic6hunter的博客 804

ACE框架解读 - 源码篇

最近学习ACE框架的源码,先考虑选取最新版本ACE6.0来阅读,但是发现代码量有30多万行,规模太大了花的时间会比较多,所以考虑选取旧一些的版本,最后选取ACE4.5版本来阅读,代码量13万行比较适中。 下面是我学习时的一些总结,把所有的目录和文件列出来,并针对每个文件里的主要类及其实现,根据自己的理解作了一些总结。 文件 总结 [CORBA]

无忧的专栏 7324

【硬核指南/MI50 32G/Ubuntu】从零部署大模型:MI50显卡Ubuntu系统驱动安装与避坑全记录

本文详细记录了在Ubuntu系统上为AMD MI50显卡安装驱动并部署大模型的完整流程,包括硬件兼容性检查、BIOS关键设置、系统安装优化、ROCm驱动安装及常见问题解决方案。特别针对MI50显卡在X99平台上的特殊配置需求提供了实用技巧,帮助用户避免常见陷阱,提升大模型训练效率。

weixin_42520909的博客 825

Linux网络编程——inet_addr()函数源代码

https://opensource.apple.com/source/Libc/Libc-166/net.subproj/inet_addr.c.auto.html /* * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. */ #include <sys/param.h> #include <netinet/in.h> #include <arpa/inet.h> #include &lt

qq_43470425的博客 2023

避坑指南:ANSYS流固耦合计算中System Coupling数据传递设置与常见报错解决

本文深入解析ANSYS Workbench中System Coupling模块在双向流固耦合(FSI)计算中的应用,详细讲解数据传递机制、典型报错解决方案及高阶调试技巧。通过实际案例展示如何优化耦合步长、处理大变形问题,并提升并行计算效率,帮助工程师有效规避常见技术陷阱。

weixin_29213525的博客 740

【首份】2023年30米分辨率土地利用遥感监测数据

为了恢复和重建我国土地利用变化的现代过程,更好地预测、预报土地利用变化趋势,地球资源数据云以美国陆地卫星Landsat 遥感影像数据作为主信息源,结合Sentinel系列数据,通过人工目视解译和机器学习方法,建立了国家尺度1:10 万比例尺多时期土地利用/土地覆盖遥感监测数据库(CNLUCC)因早期Landsat数据时空覆盖缺失,1972-1977年合成第一期数据,1978-1985年合成第二期数据,1986年起每年度生成一期数据。投影:Albers正轴等面积双标准纬线圆锥投影南标准纬线:25°N。

地球资源数据云的官方博客 3725

ACE_Acceptor::ACE_Acceptor: WSA Startup not initialized

ACE_Acceptor::ACE_Acceptor: WSA Startup not initialized

zxllds的专栏 301

LVDS信号调试必备:5分钟搞懂Xilinx IDELAYE3的TIME模式校准

本文深入解析了在Xilinx Ultrascale系列FPGA中调试LVDS信号时,如何正确使用IDELAYE3的TIME模式进行精密延迟校准。文章重点阐述了IDELAYCTRL、EN_VTC管脚与校准状态机的协同工作机制,揭秘了内置自校准(BISC)中Align_Delay的影响,并提供了从抽头值计算到实际眼图优化的完整实战方案,帮助工程师快速解决高速接口的时序问题。

joy55的博客 222

inet_addr源代码

//返回long IP int inet_addr(const char *sIp, unsigned long *lIp) { int octets[4]; int i; const char * auxCad = sIp; *lIp = 0; // Extraigo cada uno de los octetos. Atoi e

Keivin 5904

AM驱动架构—优质Mini-LED显示技术解决方案

(VR)和增强现实(AR)设备:MiniLED背光驱动方案适用于虚拟现实和增强现实设备中的显示技术,通过高亮度和高对比度的显示效果,创造更逼真的虚拟体验此外,MiniLED背光还能够实现更快的响应速度,减少图像残影,使得用户的动作在虚拟环境中更加流畅自然。以其出色的性能和广泛的应用前景备受关注是实现MiniLED显示效果的重要环节。1)更高的亮度和对比度:尺寸更小,可以在同样面积的显示屏上配置更多的LED,并且通过独立控制每一个MiniLED,可以实现更高的亮度和更细致的对比度,使得显示画面更加鲜明清晰。

isweekDN的博客 2781

【OpenClaw企业级智能体实战】第32篇:政企版OpenClaw安全落地指南——奇安信55页报告深度拆解与实战

2026年Q2,OpenClaw(俗称“龙虾”)安全风险集中爆发,公安部、工信部等监管机构密集发声,23万公网暴露实例、155个高危漏洞让企业“养虾”安全压力骤增。奇安信发布的55页《政企版龙虾安全使用指南》,以“看得清、管得住、用得好”为核心,构建了“端-网-云”三层防护体系。本文深度拆解这份报告的九大安全面与三大趋势,全景扫描奇安信、腾讯、360等头部厂商安全方案,提炼企业最低安全基线与实操配置,通过金融机构虚拟案例演示落地全流程,提供从资产摸底、规范制定到工具部署的完整解决方案。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 583

ACE源代码目录结构

ACE(ADAPTIVE Communication Environment),中文的意思就是自适配通讯环境,ACE是一个用于开发网络程序的优秀的C++的框架,在国外有很广泛的使用,在国内一些大的开发通讯产品的公司也有使用。我接触ACE也有一段时间了,虽然时间不长,但我还是感觉到AC

LzxxTeam 1958

数字信号处理(一):Xilinx Vivado DDS IP核设计实例(文末附源码)

前言 在数字信号处理时我们经常会用到数字变频,包数字下变频(DDC)和数字上变频(DUC),这其中会用到Xilinx公司的DDS IP核或者Altera公司的NCO IP核来产生本振频率,以现数字域信号频谱搬移。本文我们通过例化Xilinx公司的DDS IP核来产生混频器本振输入频率,并给出Modelsim仿真测试结果。 1、Xilinx DDS IP简介 Xilinx公司的DDS IP核使用AX...

FPGA_Designer 1万+

ACE通信框架的一些例子(包括MFC)

原文地址:http://blog.csdn.net/zhjb1025/article/details/4017001 被ACE折磨了几天以后整理出来的一些经验,和大家分享 一.              ace的编译安装 环境:XP,VC6.0+SP6,ACE5.4 1.    解压缩ace源代码包,假设在D:/ACE_wrappers 2.    使用vc打开D:/ACE_wrappe

Stone_Sky 2278

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

inet_addr函数

今天使用了在编程时使用到inet_addr函数,不太熟悉,找了点资料,整理如下。 inet_addr的功能是将一个ip地址字符串转换成一个整数值。一般的IP地址串格式为:'a.b.c.d'分成四段。 但是也会有分为1、2或3段的格式。下面我们来看看WIN2K下inet_addr函数的源码: (478条消息) inet_addr函数_misterliwei的博客-CSDN博客_inet_addr...

木牛的博客 7680

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ACE - Reactor模式源码剖析及具体实现(大量源码慎入)

原文出自http://www.cnblogs.com/binchen-china,禁止转载。 在之前的文章中提到过Reactor模式和Preactor模式,现在利用ACE的Reactor来实现一个基于Reactor框架的服务器。 首先回顾下Reactor模式和Preactor模式。 Reactor模式: Reactor模式实现非常简单,使用同步IO模型,即业务线程处理数据需要主动等待或询问

phymat.nico的专栏 618

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

ACE 开源项目教程

ACE 开源项目教程 1. 项目的目录结构及介绍 ACE 项目的目录结构如下: ACE/ ├── CMakeLists.txt ├── LICENSE ├── README.md ├── src/ │ ├── main.cpp │ ├── config.h │ ├── utils.cpp │ └── utils.h ├── include/ │ └── ace/ │ ...

gitblog_00917的博客 545

ACE_SOCK下的几个类

ACE_SOCK_Acceptor 相当于网络编程中的Acceptor 监听客户端的请求。 /* -*- C++ -*- */ //============================================================================= /** * @file SOCK_Acceptor.h * * $Id: SOCK_Acce...

kanwoerzi 213

ACE_INET的问题

初始化远程端口号时,是这样写的:remote_addr_(remote_host),也就是调用的这个函数原型:ACE_INET_Addr::ACE_INET_Addr(const char address[]);而ace帮助文档中说,这个address必须是这样的形式:"127.0.0.1:5000",如果这个字符串中没有':'的话,就会把address当成是端口号,而把ip设为I...

cpongo5 259

学习ACE网络编程(一)------使用ACE流实现TCP/IP协议传输功能

ACE中的流包装提供面向连接的通信。 基于TCP/IP传输协议需要如下ACE类库: ACE_SOCK_Acceptor 用于被动的建立连接。用于服务器端 ACE_SOCK_Connector 用于主动的连接建立。用于客户端 ACE_SOCK_IO 用于提供面向连接的消息传递服务。封装了send()、recv()和write()等调用。该类是ACE_SOCK_Stream的基类。 ACE_SOC...

mengmeng0510的博客 1636

ACE之(二)ACE Socket封装器

关注微信公众号“池边小树”~~获取更多分析~~(文末二维码~~) 2 ACE Socket封装器 这部分内容不是ACE的网络框架,而是ACE对Socket API的面向对象的封装,在ACE中称为Socket Wrapper Facade。它是ACE网络框架的基础。 ACE将Socket应用接口封装到3个不同的类中,它们是ACE_SOCK_Stream、ACE_SOCK_Acceptor和...

XingyuZhengtu的博客 1092
上一篇: dynamic_cast, reinterpret_cast, static_cast and const_cast 学习
下一篇: 多线程实现消费者生产者的例子
ctreewang
博客等级 码龄16年 1608粉丝 276原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值