Fixed typos
[ACE_TAO.git] / ACE / ace / SOCK_Dgram.inl
blobb2a116c31b98a4140b04ed81672687c74323e2e6
1 // -*- C++ -*-
2 // SOCK_Dgram.i
4 #include "ace/OS_NS_sys_socket.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
8 // Here's the simple-minded constructor.
10 ACE_INLINE
11 ACE_SOCK_Dgram::ACE_SOCK_Dgram (void)
13   ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
16 ACE_INLINE
17 ACE_SOCK_Dgram::~ACE_SOCK_Dgram (void)
19   ACE_TRACE ("ACE_SOCK_Dgram::~ACE_SOCK_Dgram");
22 // <sendto> an N byte datagram to <addr> (connectionless version).
24 ACE_INLINE ssize_t
25 ACE_SOCK_Dgram::send (const void *buf,
26                       size_t n,
27                       const ACE_Addr &addr,
28                       int flags) const
30   ACE_TRACE ("ACE_SOCK_Dgram::send");
31   sockaddr *saddr = (sockaddr *) addr.get_addr ();
32   int len = addr.get_size ();
33   return ACE_OS::sendto (this->get_handle (),
34                          (const char *) buf,
35                          n,
36                          flags,
37                          (struct sockaddr *) saddr,
38                          len);
41 // <recvfrom> an n byte datagram (connectionless version).
43 ACE_INLINE ssize_t
44 ACE_SOCK_Dgram::recv (void *buf,
45                       size_t n,
46                       ACE_Addr &addr,
47                       int flags) const
49   ACE_TRACE ("ACE_SOCK_Dgram::recv");
50   sockaddr *saddr = (sockaddr *) addr.get_addr ();
51   int addr_len = addr.get_size ();
53   ssize_t const status = ACE_OS::recvfrom (this->get_handle (),
54                                            (char *) buf,
55                                            n,
56                                            flags,
57                                            (sockaddr *) saddr,
58                                            &addr_len);
59   addr.set_size (addr_len);
60   addr.set_type (saddr->sa_family);
61   return status;
64 ACE_INLINE ssize_t
65 ACE_SOCK_Dgram::send (const iovec buffers[],
66                       int buffer_count,
67                       size_t &number_of_bytes_sent,
68                       int flags,
69                       const ACE_Addr &addr,
70                       ACE_OVERLAPPED *overlapped,
71                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
73   ACE_TRACE ("ACE_SOCK_Dgram::send");
74   sockaddr *saddr = (sockaddr *) addr.get_addr ();
75   int len = addr.get_size ();
76   return ACE_OS::sendto (this->get_handle (),
77                          buffers,
78                          buffer_count,
79                          number_of_bytes_sent,
80                          flags,
81                          (const sockaddr *) saddr,
82                          len,
83                          overlapped,
84                          func);
87 ACE_INLINE ssize_t
88 ACE_SOCK_Dgram::recv (iovec buffers[],
89                       int buffer_count,
90                       size_t &number_of_bytes_recvd,
91                       int &flags,
92                       ACE_Addr &addr,
93                       ACE_OVERLAPPED *overlapped,
94                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
96   ACE_TRACE ("ACE_SOCK_Dgram::recv");
97   sockaddr *saddr = (sockaddr *) addr.get_addr ();
98   int addr_len = addr.get_size ();
100   ssize_t status = ACE_OS::recvfrom (this->get_handle (),
101                                      buffers,
102                                      buffer_count,
103                                      number_of_bytes_recvd,
104                                      flags,
105                                      (sockaddr *) saddr,
106                                      &addr_len,
107                                      overlapped,
108                                      func);
109   addr.set_size (addr_len);
110   addr.set_type (saddr->sa_family);
111   return status;
114 // <sendto> an N byte datagram to <addr> (connectionless version).
116 ACE_INLINE ssize_t
117 ACE_SOCK_Dgram::send (const void *buf,
118                       size_t n,
119                       const ACE_Addr &addr,
120                       int flags,
121                       ACE_OVERLAPPED *overlapped,
122                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
124   ACE_TRACE ("ACE_SOCK_Dgram::send");
126   iovec buffer[1];
127   buffer[0].iov_len = static_cast<u_long> (n);  // Betting on < 4G
128   buffer[0].iov_base = (char *) buf;
129   size_t number_of_bytes_sent = 0;
130   return this->send (buffer,
131                      1,
132                      number_of_bytes_sent,
133                      flags,
134                      addr,
135                      overlapped,
136                      func);
139 // <recvfrom> an n byte datagram (connectionless version).
141 ACE_INLINE ssize_t
142 ACE_SOCK_Dgram::recv (void *buf,
143                       size_t n,
144                       ACE_Addr &addr,
145                       int flags,
146                       ACE_OVERLAPPED *overlapped,
147                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
149   ACE_TRACE ("ACE_SOCK_Dgram::recv");
151   iovec buffer[1];
152   buffer[0].iov_len = static_cast<u_long> (n);  // Betting on < 4G
153   buffer[0].iov_base = (char *) buf;
154   size_t number_of_bytes_recvd = 0;
155   return this->recv (buffer,
156                      1,
157                      number_of_bytes_recvd,
158                      flags,
159                      addr,
160                      overlapped,
161                      func);
164 ACE_END_VERSIONED_NAMESPACE_DECL