basic_datagram_socket.hpp
Go to the documentation of this file.
00001 //
00002 // basic_datagram_socket.hpp
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef ASIO_BASIC_DATAGRAM_SOCKET_HPP
00012 #define ASIO_BASIC_DATAGRAM_SOCKET_HPP
00013 
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017 
00018 #include "asio/detail/push_options.hpp"
00019 
00020 #include "asio/detail/push_options.hpp"
00021 #include <cstddef>
00022 #include <boost/config.hpp>
00023 #include "asio/detail/pop_options.hpp"
00024 
00025 #include "asio/basic_socket.hpp"
00026 #include "asio/datagram_socket_service.hpp"
00027 #include "asio/error.hpp"
00028 #include "asio/detail/throw_error.hpp"
00029 
00030 namespace asio {
00031 
00033 
00041 template <typename Protocol,
00042     typename DatagramSocketService = datagram_socket_service<Protocol> >
00043 class basic_datagram_socket
00044   : public basic_socket<Protocol, DatagramSocketService>
00045 {
00046 public:
00048   typedef typename DatagramSocketService::native_type native_type;
00049 
00051   typedef Protocol protocol_type;
00052 
00054   typedef typename Protocol::endpoint endpoint_type;
00055 
00057 
00065   explicit basic_datagram_socket(asio::io_service& io_service)
00066     : basic_socket<Protocol, DatagramSocketService>(io_service)
00067   {
00068   }
00069 
00071 
00082   basic_datagram_socket(asio::io_service& io_service,
00083       const protocol_type& protocol)
00084     : basic_socket<Protocol, DatagramSocketService>(io_service, protocol)
00085   {
00086   }
00087 
00090 
00104   basic_datagram_socket(asio::io_service& io_service,
00105       const endpoint_type& endpoint)
00106     : basic_socket<Protocol, DatagramSocketService>(io_service, endpoint)
00107   {
00108   }
00109 
00111 
00125   basic_datagram_socket(asio::io_service& io_service,
00126       const protocol_type& protocol, const native_type& native_socket)
00127     : basic_socket<Protocol, DatagramSocketService>(
00128         io_service, protocol, native_socket)
00129   {
00130   }
00131 
00133 
00154   template <typename ConstBufferSequence>
00155   std::size_t send(const ConstBufferSequence& buffers)
00156   {
00157     asio::error_code ec;
00158     std::size_t s = this->service.send(this->implementation, buffers, 0, ec);
00159     asio::detail::throw_error(ec);
00160     return s;
00161   }
00162 
00164 
00180   template <typename ConstBufferSequence>
00181   std::size_t send(const ConstBufferSequence& buffers,
00182       socket_base::message_flags flags)
00183   {
00184     asio::error_code ec;
00185     std::size_t s = this->service.send(
00186         this->implementation, buffers, flags, ec);
00187     asio::detail::throw_error(ec);
00188     return s;
00189   }
00190 
00192 
00208   template <typename ConstBufferSequence>
00209   std::size_t send(const ConstBufferSequence& buffers,
00210       socket_base::message_flags flags, asio::error_code& ec)
00211   {
00212     return this->service.send(this->implementation, buffers, flags, ec);
00213   }
00214 
00216 
00251   template <typename ConstBufferSequence, typename WriteHandler>
00252   void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
00253   {
00254     this->service.async_send(this->implementation, buffers, 0, handler);
00255   }
00256 
00258 
00286   template <typename ConstBufferSequence, typename WriteHandler>
00287   void async_send(const ConstBufferSequence& buffers,
00288       socket_base::message_flags flags, WriteHandler handler)
00289   {
00290     this->service.async_send(this->implementation, buffers, flags, handler);
00291   }
00292 
00294 
00318   template <typename ConstBufferSequence>
00319   std::size_t send_to(const ConstBufferSequence& buffers,
00320       const endpoint_type& destination)
00321   {
00322     asio::error_code ec;
00323     std::size_t s = this->service.send_to(
00324         this->implementation, buffers, destination, 0, ec);
00325     asio::detail::throw_error(ec);
00326     return s;
00327   }
00328 
00330 
00345   template <typename ConstBufferSequence>
00346   std::size_t send_to(const ConstBufferSequence& buffers,
00347       const endpoint_type& destination, socket_base::message_flags flags)
00348   {
00349     asio::error_code ec;
00350     std::size_t s = this->service.send_to(
00351         this->implementation, buffers, destination, flags, ec);
00352     asio::detail::throw_error(ec);
00353     return s;
00354   }
00355 
00357 
00372   template <typename ConstBufferSequence>
00373   std::size_t send_to(const ConstBufferSequence& buffers,
00374       const endpoint_type& destination, socket_base::message_flags flags,
00375       asio::error_code& ec)
00376   {
00377     return this->service.send_to(this->implementation,
00378         buffers, destination, flags, ec);
00379   }
00380 
00382 
00418   template <typename ConstBufferSequence, typename WriteHandler>
00419   void async_send_to(const ConstBufferSequence& buffers,
00420       const endpoint_type& destination, WriteHandler handler)
00421   {
00422     this->service.async_send_to(this->implementation, buffers, destination, 0,
00423         handler);
00424   }
00425 
00427 
00453   template <typename ConstBufferSequence, typename WriteHandler>
00454   void async_send_to(const ConstBufferSequence& buffers,
00455       const endpoint_type& destination, socket_base::message_flags flags,
00456       WriteHandler handler)
00457   {
00458     this->service.async_send_to(this->implementation, buffers, destination,
00459         flags, handler);
00460   }
00461 
00463 
00486   template <typename MutableBufferSequence>
00487   std::size_t receive(const MutableBufferSequence& buffers)
00488   {
00489     asio::error_code ec;
00490     std::size_t s = this->service.receive(
00491         this->implementation, buffers, 0, ec);
00492     asio::detail::throw_error(ec);
00493     return s;
00494   }
00495 
00497 
00514   template <typename MutableBufferSequence>
00515   std::size_t receive(const MutableBufferSequence& buffers,
00516       socket_base::message_flags flags)
00517   {
00518     asio::error_code ec;
00519     std::size_t s = this->service.receive(
00520         this->implementation, buffers, flags, ec);
00521     asio::detail::throw_error(ec);
00522     return s;
00523   }
00524 
00526 
00543   template <typename MutableBufferSequence>
00544   std::size_t receive(const MutableBufferSequence& buffers,
00545       socket_base::message_flags flags, asio::error_code& ec)
00546   {
00547     return this->service.receive(this->implementation, buffers, flags, ec);
00548   }
00549 
00551 
00586   template <typename MutableBufferSequence, typename ReadHandler>
00587   void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
00588   {
00589     this->service.async_receive(this->implementation, buffers, 0, handler);
00590   }
00591 
00593 
00620   template <typename MutableBufferSequence, typename ReadHandler>
00621   void async_receive(const MutableBufferSequence& buffers,
00622       socket_base::message_flags flags, ReadHandler handler)
00623   {
00624     this->service.async_receive(this->implementation, buffers, flags, handler);
00625   }
00626 
00628 
00653   template <typename MutableBufferSequence>
00654   std::size_t receive_from(const MutableBufferSequence& buffers,
00655       endpoint_type& sender_endpoint)
00656   {
00657     asio::error_code ec;
00658     std::size_t s = this->service.receive_from(
00659         this->implementation, buffers, sender_endpoint, 0, ec);
00660     asio::detail::throw_error(ec);
00661     return s;
00662   }
00663   
00665 
00680   template <typename MutableBufferSequence>
00681   std::size_t receive_from(const MutableBufferSequence& buffers,
00682       endpoint_type& sender_endpoint, socket_base::message_flags flags)
00683   {
00684     asio::error_code ec;
00685     std::size_t s = this->service.receive_from(
00686         this->implementation, buffers, sender_endpoint, flags, ec);
00687     asio::detail::throw_error(ec);
00688     return s;
00689   }
00690   
00692 
00707   template <typename MutableBufferSequence>
00708   std::size_t receive_from(const MutableBufferSequence& buffers,
00709       endpoint_type& sender_endpoint, socket_base::message_flags flags,
00710       asio::error_code& ec)
00711   {
00712     return this->service.receive_from(this->implementation, buffers,
00713         sender_endpoint, flags, ec);
00714   }
00715 
00717 
00752   template <typename MutableBufferSequence, typename ReadHandler>
00753   void async_receive_from(const MutableBufferSequence& buffers,
00754       endpoint_type& sender_endpoint, ReadHandler handler)
00755   {
00756     this->service.async_receive_from(this->implementation, buffers,
00757         sender_endpoint, 0, handler);
00758   }
00759 
00761 
00789   template <typename MutableBufferSequence, typename ReadHandler>
00790   void async_receive_from(const MutableBufferSequence& buffers,
00791       endpoint_type& sender_endpoint, socket_base::message_flags flags,
00792       ReadHandler handler)
00793   {
00794     this->service.async_receive_from(this->implementation, buffers,
00795         sender_endpoint, flags, handler);
00796   }
00797 };
00798 
00799 } // namespace asio
00800 
00801 #include "asio/detail/pop_options.hpp"
00802 
00803 #endif // ASIO_BASIC_DATAGRAM_SOCKET_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39