Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / TLI_Stream.cpp
blob9acc4a0a1fef6887bcda220b4b6428781682189d
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"
8 #if defined (ACE_HAS_TLI)
10 #if !defined (__ACE_INLINE__)
11 #include "ace/TLI_Stream.inl"
12 #endif /* __ACE_INLINE__ */
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Stream)
18 void
19 ACE_TLI_Stream::dump () const
21 #if defined (ACE_HAS_DUMP)
22 ACE_TRACE ("ACE_TLI_Stream::dump");
23 #endif /* ACE_HAS_DUMP */
26 ACE_TLI_Stream::ACE_TLI_Stream ()
27 : rwflag_ (0)
29 ACE_TRACE ("ACE_TLI_Stream::ACE_TLI_Stream");
32 int
33 ACE_TLI_Stream::get_remote_addr (ACE_Addr &sa) const
35 ACE_TRACE ("ACE_TLI_Stream::get_remote_addr");
37 struct netbuf name;
38 name.maxlen = sa.get_size ();
39 name.buf = (char *) sa.get_addr ();
41 if (ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME) == -1)
42 return -1;
43 else
44 return 0;
47 // Send a release and then await the release from the other side.
49 int
50 ACE_TLI_Stream::active_close ()
52 ACE_TRACE ("ACE_TLI_Stream::active_close");
53 char buf;
55 if (this->sndrel () == -1)
56 return -1;
57 else if (this->recv (&buf, sizeof buf) == -1)
59 if (t_errno == TLOOK && this->look () == T_ORDREL)
61 if (this->rcvrel () == -1)
62 return -1;
64 else
65 return -1;
68 return this->close ();
71 // Acknowledge the release from the other side and then send the
72 // release to the other side.
74 int
75 ACE_TLI_Stream::passive_close ()
77 ACE_TRACE ("ACE_TLI_Stream::passive_close");
79 if (this->rcvrel () == -1)
80 return -1;
81 else if (this->sndrel () == -1)
82 return -1;
84 return this->close ();
87 int
88 ACE_TLI_Stream::close ()
90 ACE_TRACE ("ACE_TLI_Stream::close");
92 ACE_HANDLE fd = this->get_handle ();
94 this->set_handle (ACE_INVALID_HANDLE);
96 #if !defined (ACE_WIN32)
97 if (this->rwflag_)
98 return ACE_OS::close (fd);
99 else
100 #endif /* ACE_WIN32 */
101 return ACE_OS::t_close (fd);
104 ssize_t
105 ACE_TLI_Stream::send (const void *buf,
106 size_t n,
107 const ACE_Time_Value *timeout) const
109 ACE_TRACE ("ACE_TLI_Stream::send");
110 return ACE::send (this->get_handle (),
111 buf,
113 timeout);
116 ssize_t
117 ACE_TLI_Stream::send (const void *buf,
118 size_t n,
119 int flags,
120 const ACE_Time_Value *timeout) const
122 ACE_TRACE ("ACE_TLI_Stream::send");
123 return ACE::t_snd (this->get_handle (),
124 buf,
126 flags,
127 timeout);
130 ssize_t
131 ACE_TLI_Stream::recv (void *buf,
132 size_t n,
133 const ACE_Time_Value *timeout) const
135 ACE_TRACE ("ACE_TLI_Stream::recv");
136 return ACE::recv (this->get_handle (),
137 buf,
139 timeout);
142 ssize_t
143 ACE_TLI_Stream::recv (void *buf,
144 size_t n,
145 int *flags,
146 const ACE_Time_Value *timeout) const
148 ACE_TRACE ("ACE_TLI_Stream::recv");
149 int f = 0;
151 if (flags == 0)
152 flags = &f;
154 return ACE::t_rcv (this->get_handle (),
155 buf,
157 flags,
158 timeout);
161 ssize_t
162 ACE_TLI_Stream::send_n (const void *buf,
163 size_t n,
164 const ACE_Time_Value *timeout,
165 size_t *bytes_transferred) const
167 ACE_TRACE ("ACE_TLI_Stream::send_n");
168 return ACE::send_n (this->get_handle (),
169 buf,
171 timeout,
172 bytes_transferred);
175 ssize_t
176 ACE_TLI_Stream::send_n (const void *buf,
177 size_t n,
178 int flags,
179 const ACE_Time_Value *timeout,
180 size_t *bytes_transferred) const
182 ACE_TRACE ("ACE_TLI_Stream::send_n");
184 return ACE::t_snd_n (this->get_handle (),
185 buf,
187 flags,
188 timeout,
189 bytes_transferred);
192 ssize_t
193 ACE_TLI_Stream::recv_n (void *buf,
194 size_t n,
195 const ACE_Time_Value *timeout,
196 size_t *bytes_transferred) const
198 ACE_TRACE ("ACE_TLI_Stream::recv_n");
199 return ACE::recv_n (this->get_handle (),
200 buf,
202 timeout,
203 bytes_transferred);
206 ssize_t
207 ACE_TLI_Stream::recv_n (void *buf,
208 size_t n,
209 int *flags,
210 const ACE_Time_Value *timeout,
211 size_t *bytes_transferred) const
213 ACE_TRACE ("ACE_TLI_Stream::recv_n");
215 return ACE::t_rcv_n (this->get_handle (),
216 buf,
218 flags,
219 timeout,
220 bytes_transferred);
223 ACE_END_VERSIONED_NAMESPACE_DECL
225 #endif /* ACE_HAS_TLI */