Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

SOCK_Dgram.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: SOCK_Dgram.i,v 1.1.1.3 2003/02/21 18:36:32 chad Exp $
00003 
00004 // SOCK_Dgram.i
00005 
00006 // Here's the simple-minded constructor. 
00007 
00008 ASYS_INLINE
00009 ACE_SOCK_Dgram::ACE_SOCK_Dgram (void)
00010 {
00011   ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
00012 }
00013 
00014 ASYS_INLINE
00015 ACE_SOCK_Dgram::~ACE_SOCK_Dgram (void)
00016 {
00017   ACE_TRACE ("ACE_SOCK_Dgram::~ACE_SOCK_Dgram");
00018 }
00019 
00020 // <sendto> an N byte datagram to <addr> (connectionless version).
00021 
00022 ASYS_INLINE ssize_t
00023 ACE_SOCK_Dgram::send (const void *buf, 
00024                       size_t n, 
00025                       const ACE_Addr &addr, 
00026                       int flags) const
00027 {
00028   ACE_TRACE ("ACE_SOCK_Dgram::send");
00029   sockaddr *saddr = (sockaddr *) addr.get_addr ();
00030   int len = addr.get_size ();
00031   return ACE_OS::sendto (this->get_handle (), 
00032                          (const char *) buf,
00033                          n,
00034                          flags, 
00035                          (struct sockaddr *) saddr,
00036                          len);
00037 }
00038 
00039 // <recvfrom> an n byte datagram (connectionless version).
00040 
00041 ASYS_INLINE ssize_t
00042 ACE_SOCK_Dgram::recv (void *buf, 
00043                       size_t n, 
00044                       ACE_Addr &addr, 
00045                       int flags) const
00046 {
00047   ACE_TRACE ("ACE_SOCK_Dgram::recv");
00048   sockaddr *saddr = (sockaddr *) addr.get_addr ();
00049   int addr_len = addr.get_size ();
00050 
00051   ssize_t status = ACE_OS::recvfrom (this->get_handle (), 
00052                                      (char *) buf,
00053                                      n,
00054                                      flags, 
00055                                      (sockaddr *) saddr,
00056                                      &addr_len);
00057   addr.set_size (addr_len);
00058   return status;
00059 }
00060 
00061 ASYS_INLINE ssize_t
00062 ACE_SOCK_Dgram::send (const iovec buffers[],
00063                       int buffer_count,
00064                       size_t &number_of_bytes_sent,
00065                       int flags,
00066                       const ACE_Addr &addr,
00067                       ACE_OVERLAPPED *overlapped,
00068                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
00069 {
00070   ACE_TRACE ("ACE_SOCK_Dgram::send");
00071   sockaddr *saddr = (sockaddr *) addr.get_addr ();
00072   int len = addr.get_size ();
00073   return ACE_OS::sendto (this->get_handle (), 
00074                          buffers,
00075                          buffer_count,
00076                          number_of_bytes_sent,
00077                          flags, 
00078                          (const sockaddr *) saddr,
00079                          len,
00080                          overlapped,
00081                          func);
00082 }
00083 
00084 ASYS_INLINE ssize_t
00085 ACE_SOCK_Dgram::recv (iovec buffers[],
00086                       int buffer_count,
00087                       size_t &number_of_bytes_recvd,
00088                       int &flags,
00089                       ACE_Addr &addr,
00090                       ACE_OVERLAPPED *overlapped,
00091                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
00092 {
00093   ACE_TRACE ("ACE_SOCK_Dgram::recv");
00094   sockaddr *saddr = (sockaddr *) addr.get_addr ();
00095   int addr_len = addr.get_size ();
00096 
00097   ssize_t status = ACE_OS::recvfrom (this->get_handle (), 
00098                                      buffers,
00099                                      buffer_count,
00100                                      number_of_bytes_recvd,
00101                                      flags, 
00102                                      (sockaddr *) saddr,
00103                                      &addr_len,
00104                                      overlapped,
00105                                      func);
00106   addr.set_size (addr_len);
00107   return status;
00108 }
00109 
00110 // <sendto> an N byte datagram to <addr> (connectionless version).
00111 
00112 ASYS_INLINE ssize_t
00113 ACE_SOCK_Dgram::send (const void *buf, 
00114                       size_t n, 
00115                       const ACE_Addr &addr, 
00116                       int flags,
00117                       ACE_OVERLAPPED *overlapped,
00118                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
00119 {
00120   ACE_TRACE ("ACE_SOCK_Dgram::send");
00121 
00122   iovec buffer[1];
00123   buffer[0].iov_len = ACE_static_cast (u_long, n);  // Betting on < 4G
00124   buffer[0].iov_base = (char *) buf;
00125   size_t number_of_bytes_sent = 0;
00126   return this->send (buffer,
00127                      1,
00128                      number_of_bytes_sent,
00129                      flags,
00130                      addr,
00131                      overlapped,
00132                      func);
00133 }
00134 
00135 // <recvfrom> an n byte datagram (connectionless version).
00136 
00137 ASYS_INLINE ssize_t
00138 ACE_SOCK_Dgram::recv (void *buf, 
00139                       size_t n, 
00140                       ACE_Addr &addr, 
00141                       int flags,
00142                       ACE_OVERLAPPED *overlapped,
00143                       ACE_OVERLAPPED_COMPLETION_FUNC func) const
00144 {
00145   ACE_TRACE ("ACE_SOCK_Dgram::recv");
00146 
00147   iovec buffer[1];
00148   buffer[0].iov_len = ACE_static_cast (u_long, n);  // Betting on < 4G
00149   buffer[0].iov_base = (char *) buf;
00150   size_t number_of_bytes_recvd = 0;
00151   return this->recv (buffer,
00152                      1,
00153                      number_of_bytes_recvd,
00154                      flags,
00155                      addr,
00156                      overlapped,
00157                      func);
00158 }

Generated on Mon Jun 16 11:21:19 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002