Rev 1597 | Rev 1642 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1597 | Rev 1599 | ||
|---|---|---|---|
| Line 29... | Line 29... | ||
| 29 | { |
29 | { |
| 30 | } |
30 | } |
| 31 | 31 | ||
| 32 | UdpClient::~UdpClient() |
32 | UdpClient::~UdpClient() |
| 33 | { |
33 | { |
| 34 | if (this->socket_.use_count() != 0) |
- | |
| 35 | { |
- | |
| 36 | this->socket_->cancel(); |
- | |
| 37 | this->socket_->close(); |
- | |
| 38 | this->socket_.reset(); |
- | |
| 39 | } |
- | |
| 40 | } |
34 | } |
| 41 | 35 | ||
| 42 | void UdpClient::Connect(std::string address, unsigned int port) |
36 | void UdpClient::Connect(std::string address, unsigned int port) |
| 43 | { |
37 | { |
| 44 | try |
38 | try |
| Line 55... | Line 49... | ||
| 55 | { |
49 | { |
| 56 | throw std::runtime_error("Error while connecting to " + address + ":" + boost::lexical_cast<std::string>(port) + ", " + e.what()); |
50 | throw std::runtime_error("Error while connecting to " + address + ":" + boost::lexical_cast<std::string>(port) + ", " + e.what()); |
| 57 | } |
51 | } |
| 58 | 52 | ||
| 59 | this->Read(); |
53 | this->Read(); |
| 60 | } |
54 | } |
| 61 | 55 | ||
| 62 | void UdpClient:: |
56 | void UdpClient::Stop() |
| 63 | { |
57 | { |
| 64 | if (this->socket_.use_count() != 0) |
58 | if (this->socket_.use_count() != 0) |
| 65 | { |
59 | { |
| 66 | this->socket_->cancel(); |
60 | this->socket_->cancel(); |
| 67 | this->socket_->close(); |
61 | this->socket_->close(); |
| 68 | this->socket_.reset(); |
62 | this->socket_.reset(); |
| 69 | } |
63 | } |
| 70 | - | ||
| 71 | Client::Disconnect(); |
- | |
| 72 | } |
64 | } |
| 73 | 65 | ||
| 74 | void UdpClient::Send(type::Byteset data) |
66 | void UdpClient::Send(type::Byteset data) |
| 75 | { |
67 | { |
| 76 | try |
68 | try |
| Line 95... | Line 87... | ||
| 95 | boost::bind(&UdpClient::ReadHandler, |
87 | boost::bind(&UdpClient::ReadHandler, |
| 96 | this, |
88 | this, |
| 97 | boost::asio::placeholders::error, |
89 | boost::asio::placeholders::error, |
| 98 | boost::asio::placeholders::bytes_transferred)); |
90 | boost::asio::placeholders::bytes_transferred)); |
| 99 | } |
91 | } |
| 100 | - | ||
| 101 | 92 | ||
| 102 | }; // namespace net |
93 | }; // namespace net |
| 103 | }; // namespace atom |
94 | }; // namespace atom |