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