00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file SPIPE_Connector.h 00006 * 00007 * SPIPE_Connector.h,v 4.22 2005/10/28 16:14:55 ossama Exp 00008 * 00009 * @author Doug Schmidt <schmidt@cs.wustl.edu> 00010 * @author Prashant Jain <pjain@cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef ACE_SPIPE_CONNECTOR_H 00015 #define ACE_SPIPE_CONNECTOR_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/SPIPE_Stream.h" 00019 #include "ace/os_include/os_fcntl.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 /** 00028 * @class ACE_SPIPE_Connector 00029 * 00030 * @brief Defines an active connection factory for <ACE_SPIPE_Stream>. 00031 * On Windows this is mapped to Named Pipes, whereas on UNIX it is 00032 * mapped to STREAM pipes. 00033 */ 00034 class ACE_Export ACE_SPIPE_Connector 00035 { 00036 public: 00037 // = Initialization method. 00038 /// Default constructor. 00039 ACE_SPIPE_Connector (void); 00040 00041 /** 00042 * Actively connect and produce a <new_stream> if things go well. 00043 * The <remote_sap> is the address that we are trying to connect 00044 * with. The <timeout> is the amount of time to wait to connect. 00045 * If it's 0 then we block indefinitely. If *timeout == {0, 0} then 00046 * the connection is done using non-blocking mode. In this case, if 00047 * the connection can't be made immediately the value of -1 is 00048 * returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then 00049 * this is the maximum amount of time to wait before timing out. If the 00050 * time expires before the connection is made <errno == ETIME>. The 00051 * <local_sap> is the value of local address to bind to. If it's 00052 * the default value of <ACE_Addr::sap_any> then the user is letting 00053 * the OS do the binding. If <reuse_addr> == 1 then the 00054 * <local_addr> is reused, even if it hasn't been cleanedup yet. 00055 * The <flags> and <perms> arguments are passed down to the <open> 00056 * method. The <pipe_mode> argument is only used in NT and is used to 00057 * establish the NT pipe mode. 00058 */ 00059 ACE_SPIPE_Connector (ACE_SPIPE_Stream &new_io, 00060 const ACE_SPIPE_Addr &remote_sap, 00061 ACE_Time_Value *timeout = 0, 00062 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00063 int reuse_addr = 0, 00064 int flags = O_RDWR, 00065 int perms = 0, 00066 LPSECURITY_ATTRIBUTES sa = 0, 00067 int pipe_mode = PIPE_READMODE_MESSAGE | PIPE_WAIT); 00068 00069 /** 00070 * Actively connect and produce a <new_stream> if things go well. 00071 * The <remote_sap> is the address that we are trying to connect 00072 * with. The <timeout> is the amount of time to wait to connect. 00073 * If it's 0 then we block indefinitely. If *timeout == {0, 0} then 00074 * the connection is done using non-blocking mode. In this case, if 00075 * the connection can't be made immediately the value of -1 is 00076 * returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then 00077 * this is the maximum amount of time to wait before timing out. If the 00078 * time expires before the connection is made <errno == ETIME>. The 00079 * <local_sap> is the value of local address to bind to. If it's 00080 * the default value of <ACE_Addr::sap_any> then the user is letting 00081 * the OS do the binding. If <reuse_addr> == 1 then the 00082 * <local_addr> is reused, even if it hasn't been cleanedup yet. 00083 * The <flags> and <perms> arguments are passed down to the <open> 00084 * method. The <pipe_mode> argument is only used in NT and is used to 00085 * establish the NT pipe mode. 00086 */ 00087 int connect (ACE_SPIPE_Stream &new_io, 00088 const ACE_SPIPE_Addr &remote_sap, 00089 ACE_Time_Value *timeout = 0, 00090 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00091 int reuse_addr = 0, 00092 int flags = O_RDWR, 00093 int perms = 0, 00094 LPSECURITY_ATTRIBUTES sa = 0, 00095 int pipe_mode = PIPE_READMODE_MESSAGE | PIPE_WAIT); 00096 00097 /// Resets any event associations on this handle 00098 int reset_new_handle (ACE_HANDLE handle); 00099 00100 // = Meta-type info 00101 typedef ACE_SPIPE_Addr PEER_ADDR; 00102 typedef ACE_SPIPE_Stream PEER_STREAM; 00103 00104 /// Dump the state of an object. 00105 void dump (void) const; 00106 00107 /// Declare the dynamic allocation hooks. 00108 ACE_ALLOC_HOOK_DECLARE; 00109 }; 00110 00111 ACE_END_VERSIONED_NAMESPACE_DECL 00112 00113 #if defined (__ACE_INLINE__) 00114 #include "ace/SPIPE_Connector.inl" 00115 #endif /* __ACE_INLINE__ */ 00116 00117 #include /**/ "ace/post.h" 00118 #endif /* ACE_SPIPE_CONNECTOR_H */