2013-03-24 04:11:28 +00:00
|
|
|
#pragma once
|
2012-09-09 03:46:19 +00:00
|
|
|
#include <fc/utility.hpp>
|
2012-11-25 00:39:19 +00:00
|
|
|
#include <fc/shared_ptr.hpp>
|
2014-09-09 15:10:37 +00:00
|
|
|
#include <memory>
|
2012-09-09 03:46:19 +00:00
|
|
|
|
|
|
|
|
namespace fc {
|
|
|
|
|
namespace ip {
|
|
|
|
|
class endpoint;
|
2013-03-24 04:11:28 +00:00
|
|
|
class address;
|
2012-09-09 03:46:19 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-25 00:39:19 +00:00
|
|
|
/**
|
|
|
|
|
* The udp_socket class has reference semantics, all copies will
|
|
|
|
|
* refer to the same underlying socket.
|
|
|
|
|
*/
|
2012-09-09 03:46:19 +00:00
|
|
|
class udp_socket {
|
|
|
|
|
public:
|
|
|
|
|
udp_socket();
|
2012-11-25 00:39:19 +00:00
|
|
|
udp_socket( const udp_socket& s );
|
2012-09-09 03:46:19 +00:00
|
|
|
~udp_socket();
|
|
|
|
|
|
|
|
|
|
void open();
|
|
|
|
|
void set_receive_buffer_size( size_t s );
|
|
|
|
|
void bind( const fc::ip::endpoint& );
|
|
|
|
|
size_t receive_from( char* b, size_t l, fc::ip::endpoint& from );
|
2014-09-12 23:42:25 +00:00
|
|
|
size_t receive_from( const std::shared_ptr<char>& b, size_t l, fc::ip::endpoint& from );
|
2012-09-09 03:46:19 +00:00
|
|
|
size_t send_to( const char* b, size_t l, const fc::ip::endpoint& to );
|
2014-09-12 23:42:25 +00:00
|
|
|
size_t send_to( const std::shared_ptr<const char>& b, size_t l, const fc::ip::endpoint& to );
|
2012-09-09 03:46:19 +00:00
|
|
|
void close();
|
|
|
|
|
|
2013-03-24 04:11:28 +00:00
|
|
|
void set_multicast_enable_loopback( bool );
|
|
|
|
|
void set_reuse_address( bool );
|
|
|
|
|
void join_multicast_group( const fc::ip::address& a );
|
|
|
|
|
|
2012-09-10 03:54:11 +00:00
|
|
|
void connect( const fc::ip::endpoint& e );
|
|
|
|
|
fc::ip::endpoint local_endpoint()const;
|
|
|
|
|
|
2012-09-09 03:46:19 +00:00
|
|
|
private:
|
2012-11-25 00:39:19 +00:00
|
|
|
class impl;
|
|
|
|
|
fc::shared_ptr<impl> my;
|
2012-09-09 03:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|