ACE 简单常用类整理(一)

来源:互联网 发布:mac怎么放光盘 编辑:程序博客网 时间:2024/05/17 15:39

面向连接的相关类

1 面向连接的相关类    

ACE Class

Description

ACE_Addr

The root of the ACE network addressing hierarchy.

ACE_INET_Addr

Encapsulates the Internet-domain address family.

ACE_IPC_SAP

The root of the ACE IPC wrapper facade hierarchy.

ACE_SOCK

The root of the ACE Socket wrapper facade hierarchy.

ACE_SOCK_Connector

A factory that connects to a peer acceptor and then initializes a new endpoint of communication in an ACE_SOCK_Stream object.

ACE_SOCK_IO ACE_SOCK_Stream

Encapsulate the data transfer mechanisms supported by data-mode sockets.

ACE_SOCK_Acceptor

A factory that initializes a new endpoint of communication in an ACE_SOCK_Stream object in response to a connection request from a peer connector.

 

 

w        ACE_Addr

Method

Description

operator==()

Compares addresses for equality.

operator!=()

Compares addresses for inequality.

hash()

Computes a hash value for an address.

w        ACE_INET_Addr

Method

Description

ACE_INET_Addr(port: unsigned short, host: const char *)

set(port: unsigned short, host: const char *): int

Initialize an ACE_INET_Addr with hostnames, IP ad dresses, and/or port numbers.

string_to_addr(address: const char *) : int

Converts a string to an ACE_INET_Addr.

addr_to_string(s: char *, max: size_t, ipfmt: int =1) : int

Converts an ACE_INET_Addr to a string.

get_port_number() : u_short

Returns the port number in host byte order.

get_host_name(buff: char *, max : size_t) : int

Returns the host name.

w        ACE_IPC_SAP

Method

Description

enable()

disable()

Enable or disable various I/O handle options, such as enabling/disabling non-blocking I/O.

set_handle()

get_handle()

Set and get the underlying I/O handle.

w        ACE_SOCK

Method

Description

open(type: int, proto_family: int, protocol : int, reuse_addr : int) : int

close() : int

Create and destroy a socket endpoint of communication.

get_local_addr(addr : ACE_Addr&) : int

get_remote_addr(addr : ACE_Addr&) : int

Return the address of the local and remote peer, respectively.

set_option(level: int, options : int, optval: void *, optlen: int) : int get_option(level: int, option : int, optval: void *, optlen: int *) : int

Set and get socket options.

w        ACE_SOCK_Connector

Method

Description

connect(stream : ACE_SOCK_Stream&,

       remote_addr: ACE_Addr&,

       timeout: ACE_Time_Value* = 0) : int

Actively connects an ACE_SOCK_Stream at a particular network address using either blocking, nonblocking, or timed mode.

complete(stream : ACE_SOCK_Stream&,

       remote_addr: ACE_Addr* = 0,

       timeout: ACE_Time_Value* = 0) : int

Tries to complete a nonblocking connection and initialize an ACE_SOCK_Stream.

ACE_Time_Value

NULL: Indicates connect() should wait indefinitely, that is, block until the connection is established or the OS deems the server host unreachable.

NON-NULL == 0: Indicates connect() should perform a non-blocking connection, that is, if the connection isn't established immediately, return ? and set errno to EWOULDBLOCK.

NON-NULL > 0: Indicates connect() should only wait a relative amount of time to establish the connection, returning ? with errno set to ETIME if it can't establish the connection by then.

w        ACE_SOCK_IO and ACE_SOCK_Stream

Method

Description

send(buf: void *, n : size_t,

    timeout: ACE_Time_Value * =0) : int

recv(buf: void *, n : size_t,

    timeout: ACE_Time_Value * =0) : int

Transmit and receive buffers of data. They may write or read less than the number of bytes requested due to buffering in the OS and flow control in the transport protocol.  ACE_SOCK_IO owns.

send_n(buf: void *, len : size_t, timeout: ACE_Time_Value * =0,

      bytes_recvd: size_t * =0 ) : ssize_t

send_n(mblk: ACE_Message_Block *,

      timeout: ACE_Time_Value * =0,

      bytes_recvd: size_t * =0 ) : ssize_t

recv_n(buf: void *, len : size_t, timeout: ACE_Time_Value * =0,

      bytes_recvd: size_t * =0 ) : ssize_t

Transmit and receive data buffers of exactly n bytes to simplify application handling of "short-writes" and "short-reads."

recvv_n(v: iovec[], cnt: size_t, timeout: ACE_Time_Value * = 0,

      bytes_recd: size_t * = 0): ssize_t

Receives multiple buffers of data efficiently and completely using an OS "scatter-read" system function.

sendv_n(v: iovec[], cnt: size_t, timeout: ACE_Time_Value * = 0,

      bytes_recd: size_t * = 0): ssize_t

Sends multiple buffers of data efficiently and completely using an OS "gather-write" system function.

w        ACE_SOCK_Acceptor

Method

Description

open(local_addr: ACE_Addr&):int  

Initializes the passive-mode factory socket to listen passively at a designated ACE_INET_Addr address.

accept(stream: ACE_SOCK_Stream&): int

Initializes the ACE_SOCK stream parameter with a newly accepted client connection.

 

 

w        ACE_Message_Block

The ACE_Message_Block class enables efficient manipulation of fixed- and variable-sized messages. Each ACE_Message_Block contains a pointer to a reference-counted ACE_Data_Block, which in turn points to the actual data associated with a message. It allows multiple messages to be chained together. It allows multiple messages to be joined together in a doubly linked list that forms the basis of the ACE_Message_Queue class It treats synchronization and memory management properties that applications can vary without changing the underlying ACE_Message_Block implementation

Method

Description

ACE Message Block ()

init (size: size_t):int

Initialize the message.

msg_type(type: ACE_Message_Type)

msg_type() : ACE_Message_Type

Set and get the message type.

msg_priority(prio: u_long)

msg_priority() : u_long

Set and get the message priority.

clone() : ACE_Message_Block *

Returns an exact "deep copy" of the entire message.

duplicate() : ACE_Message_Block *

Returns a "shallow" copy of the message that increments its reference count by 1.

release(): ACE_Message_Block *

Decrements the reference count by 1 and releases the message resources if the count drops to 0.

set_flags(flags : u_long ) : u_long

Bitwise-OR the specified bits into the existing set of flags that determine the message semantics, for example, whether to delete the buffer when the message is released, and so on.

clr_flags(flags : u_long) : u_long

Clears the designated flag bits.

copy(buf : const char *, n : size_t) : int

Copies n bytes from a buffer into the message.

rd_ptr(n : size_t)

rd_ptr() : char *

Set and get the read pointer.

wr_ptr(n : size_t)

wr_ptr() : char *

Set and get the write pointer.

cont()

Set and get the message continuation field, which chains together composite messages.

next() prev()

Set and get the pointers to the doubly linked list of messages in an ACE_Message_Queue.

length() : size_t

Set and get the current length of the message, which is defined as wr_ptr () ?rd_ptr().

total_length() size_t

Gets the length of the message, including all chained message blocks.

size() : size_t

Set and get the total capacity of the message, which includes the amount of storage allocated before and beyond the [rd_ptr() , wr_ptr()] range.

w        ACE_InputCDR and ACE_OutputCDR Classes

The ACE_OutputCDR and ACE_InputCDR classes provide a highly optimized, portable, and convenient means to marshal and demarshal data

ACE_ OutputCDR creates a CDR buffer from a data structure (marshaling) and ACE_InputCDR extracts data from a CDR buffer (demarshaling).

ACE_OutputCDR

Method

Description

ACE_OutputCDR()

Creates an empty CDR stream for insertion.

write_type(x: type) : Boolean

Inserts a primitive into the stream, for example, write_ ushort().

write_type_array(x : type *, size: utype) : Boolean

Inserts an array of primitives into the stream, for example, write_long_array().

operator<<(s: ACE_OutputCDR &, x: UShort)

An insertion operator is defined for each primitive type.

good_bit() : int

Returns 0 if the stream has detected an error.

total_length() : size_t

Returns the number of bytes in the stream.

begin() : ACE_Message_Block*

Returns a pointer to the first message block in the chain.

end() : ACE_Message_Block *

Returns a pointer to the last message block in the chain.

ACE_InputCDR

Method

Description

ACE_InputCDR()

Creates an empty CDR stream for extraction.

read_type(x: type &) : bool

Extracts a primitive from the stream, for example, read char().

read_*_array(x: Octet *, size: ULong ) : bool

Extracts an array of primitives from the stream, for example, read octet_array().

operator>>(s: ACE_InputCDR&, x: char) : bool

An extraction operator is defined for each primitive type.

good bit() : int

Returns 0 if the stream has detected an error.

steal_contents() : ACE_Message_Block *

Returns a copy of the underlying ACE_Message_Block containing the current CDR stream.

原创粉丝点击