Removed ACE_HAS_BSTRING, not used
[ACE_TAO.git] / ACE / ace / TLI_Stream.cpp
blob3f20739a4775eb67e3d536c3b2a99bf7c59c658a
1 /* Defines the member functions for the base class of the ACE_TLI_Stream
2 abstraction. */
4 #include "ace/TLI_Stream.h"
5 #include "ace/ACE.h"
6 #include "ace/OS_NS_unistd.h"
10 #if defined (ACE_HAS_TLI)
12 #if !defined (__ACE_INLINE__)
13 #include "ace/TLI_Stream.inl"
14 #endif /* __ACE_INLINE__ */
16 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
18 ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Stream)
20 void
21 ACE_TLI_Stream::dump (void) const
23 #if defined (ACE_HAS_DUMP)
24 ACE_TRACE ("ACE_TLI_Stream::dump");
25 #endif /* ACE_HAS_DUMP */
28 ACE_TLI_Stream::ACE_TLI_Stream (void)
29 : rwflag_ (0)
31 ACE_TRACE ("ACE_TLI_Stream::ACE_TLI_Stream");
34 int
35 ACE_TLI_Stream::get_remote_addr (ACE_Addr &sa) const
37 ACE_TRACE ("ACE_TLI_Stream::get_remote_addr");
39 struct netbuf name;
40 name.maxlen = sa.get_size ();
41 name.buf = (char *) sa.get_addr ();
43 if (ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME) == -1)
44 return -1;
45 else
46 return 0;
49 // Send a release and then await the release from the other side.
51 int
52 ACE_TLI_Stream::active_close (void)
54 ACE_TRACE ("ACE_TLI_Stream::active_close");
55 char buf;
57 if (this->sndrel () == -1)
58 return -1;
59 else if (this->recv (&buf, sizeof buf) == -1)
61 if (t_errno == TLOOK && this->look () == T_ORDREL)
63 if (this->rcvrel () == -1)
64 return -1;
66 else
67 return -1;
70 return this->close ();
73 // Acknowledge the release from the other side and then send the
74 // release to the other side.
76 int
77 ACE_TLI_Stream::passive_close (void)
79 ACE_TRACE ("ACE_TLI_Stream::passive_close");
81 if (this->rcvrel () == -1)
82 return -1;
83 else if (this->sndrel () == -1)
84 return -1;
86 return this->close ();
89 int
90 ACE_TLI_Stream::close (void)
92 ACE_TRACE ("ACE_TLI_Stream::close");
94 ACE_HANDLE fd = this->get_handle ();
96 this->set_handle (ACE_INVALID_HANDLE);
98 #if !defined (ACE_WIN32)
99 if (this->rwflag_)
100 return ACE_OS::close (fd);
101 else
102 #endif /* ACE_WIN32 */
103 return ACE_OS::t_close (fd);
106 ssize_t
107 ACE_TLI_Stream::send (const void *buf,
108 size_t n,
109 const ACE_Time_Value *timeout) const
111 ACE_TRACE ("ACE_TLI_Stream::send");
112 return ACE::send (this->get_handle (),
113 buf,
115 timeout);
118 ssize_t
119 ACE_TLI_Stream::send (const void *buf,
120 size_t n,
121 int flags,
122 const ACE_Time_Value *timeout) const
124 ACE_TRACE ("ACE_TLI_Stream::send");
125 return ACE::t_snd (this->get_handle (),
126 buf,
128 flags,
129 timeout);
132 ssize_t
133 ACE_TLI_Stream::recv (void *buf,
134 size_t n,
135 const ACE_Time_Value *timeout) const
137 ACE_TRACE ("ACE_TLI_Stream::recv");
138 return ACE::recv (this->get_handle (),
139 buf,
141 timeout);
144 ssize_t
145 ACE_TLI_Stream::recv (void *buf,
146 size_t n,
147 int *flags,
148 const ACE_Time_Value *timeout) const
150 ACE_TRACE ("ACE_TLI_Stream::recv");
151 int f = 0;
153 if (flags == 0)
154 flags = &f;
156 return ACE::t_rcv (this->get_handle (),
157 buf,
159 flags,
160 timeout);
163 ssize_t
164 ACE_TLI_Stream::send_n (const void *buf,
165 size_t n,
166 const ACE_Time_Value *timeout,
167 size_t *bytes_transferred) const
169 ACE_TRACE ("ACE_TLI_Stream::send_n");
170 return ACE::send_n (this->get_handle (),
171 buf,
173 timeout,
174 bytes_transferred);
177 ssize_t
178 ACE_TLI_Stream::send_n (const void *buf,
179 size_t n,
180 int flags,
181 const ACE_Time_Value *timeout,
182 size_t *bytes_transferred) const
184 ACE_TRACE ("ACE_TLI_Stream::send_n");
186 return ACE::t_snd_n (this->get_handle (),
187 buf,
189 flags,
190 timeout,
191 bytes_transferred);
194 ssize_t
195 ACE_TLI_Stream::recv_n (void *buf,
196 size_t n,
197 const ACE_Time_Value *timeout,
198 size_t *bytes_transferred) const
200 ACE_TRACE ("ACE_TLI_Stream::recv_n");
201 return ACE::recv_n (this->get_handle (),
202 buf,
204 timeout,
205 bytes_transferred);
208 ssize_t
209 ACE_TLI_Stream::recv_n (void *buf,
210 size_t n,
211 int *flags,
212 const ACE_Time_Value *timeout,
213 size_t *bytes_transferred) const
215 ACE_TRACE ("ACE_TLI_Stream::recv_n");
217 return ACE::t_rcv_n (this->get_handle (),
218 buf,
220 flags,
221 timeout,
222 bytes_transferred);
225 ACE_END_VERSIONED_NAMESPACE_DECL
227 #endif /* ACE_HAS_TLI */