summaryrefslogtreecommitdiff
path: root/ace/SOCK_Dgram.i
blob: efcb0b09974602ae34b489c7730fb82675f367b3 (plain)
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
/* -*- C++ -*- */
// $Id$

// SOCK_Dgram.i

// Here's the simple-minded constructor. 

ASYS_INLINE
ACE_SOCK_Dgram::ACE_SOCK_Dgram (void)
{
  ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
}

ASYS_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).

ASYS_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 ();
  size_t 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).

ASYS_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 status = ACE_OS::recvfrom (this->get_handle (), 
				     (char *) buf, n, flags, 
				     (sockaddr *) saddr, &addr_len);
  addr.set_size (addr_len);
  return status;
}