| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/base/asyncsocket.h" | |
| 12 #include "webrtc/base/checks.h" | |
| 13 | |
| 14 namespace rtc { | |
| 15 | |
| 16 AsyncSocket::AsyncSocket() { | |
| 17 } | |
| 18 | |
| 19 AsyncSocket::~AsyncSocket() { | |
| 20 } | |
| 21 | |
| 22 AsyncSocketAdapter::AsyncSocketAdapter(AsyncSocket* socket) : socket_(nullptr) { | |
| 23 Attach(socket); | |
| 24 } | |
| 25 | |
| 26 AsyncSocketAdapter::~AsyncSocketAdapter() { | |
| 27 delete socket_; | |
| 28 } | |
| 29 | |
| 30 void AsyncSocketAdapter::Attach(AsyncSocket* socket) { | |
| 31 RTC_DCHECK(!socket_); | |
| 32 socket_ = socket; | |
| 33 if (socket_) { | |
| 34 socket_->SignalConnectEvent.connect(this, | |
| 35 &AsyncSocketAdapter::OnConnectEvent); | |
| 36 socket_->SignalReadEvent.connect(this, &AsyncSocketAdapter::OnReadEvent); | |
| 37 socket_->SignalWriteEvent.connect(this, &AsyncSocketAdapter::OnWriteEvent); | |
| 38 socket_->SignalCloseEvent.connect(this, &AsyncSocketAdapter::OnCloseEvent); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 SocketAddress AsyncSocketAdapter::GetLocalAddress() const { | |
| 43 return socket_->GetLocalAddress(); | |
| 44 } | |
| 45 | |
| 46 SocketAddress AsyncSocketAdapter::GetRemoteAddress() const { | |
| 47 return socket_->GetRemoteAddress(); | |
| 48 } | |
| 49 | |
| 50 int AsyncSocketAdapter::Bind(const SocketAddress& addr) { | |
| 51 return socket_->Bind(addr); | |
| 52 } | |
| 53 | |
| 54 int AsyncSocketAdapter::Connect(const SocketAddress& addr) { | |
| 55 return socket_->Connect(addr); | |
| 56 } | |
| 57 | |
| 58 int AsyncSocketAdapter::Send(const void* pv, size_t cb) { | |
| 59 return socket_->Send(pv, cb); | |
| 60 } | |
| 61 | |
| 62 int AsyncSocketAdapter::SendTo(const void* pv, | |
| 63 size_t cb, | |
| 64 const SocketAddress& addr) { | |
| 65 return socket_->SendTo(pv, cb, addr); | |
| 66 } | |
| 67 | |
| 68 int AsyncSocketAdapter::Recv(void* pv, size_t cb, int64_t* timestamp) { | |
| 69 return socket_->Recv(pv, cb, timestamp); | |
| 70 } | |
| 71 | |
| 72 int AsyncSocketAdapter::RecvFrom(void* pv, | |
| 73 size_t cb, | |
| 74 SocketAddress* paddr, | |
| 75 int64_t* timestamp) { | |
| 76 return socket_->RecvFrom(pv, cb, paddr, timestamp); | |
| 77 } | |
| 78 | |
| 79 int AsyncSocketAdapter::Listen(int backlog) { | |
| 80 return socket_->Listen(backlog); | |
| 81 } | |
| 82 | |
| 83 AsyncSocket* AsyncSocketAdapter::Accept(SocketAddress* paddr) { | |
| 84 return socket_->Accept(paddr); | |
| 85 } | |
| 86 | |
| 87 int AsyncSocketAdapter::Close() { | |
| 88 return socket_->Close(); | |
| 89 } | |
| 90 | |
| 91 int AsyncSocketAdapter::GetError() const { | |
| 92 return socket_->GetError(); | |
| 93 } | |
| 94 | |
| 95 void AsyncSocketAdapter::SetError(int error) { | |
| 96 return socket_->SetError(error); | |
| 97 } | |
| 98 | |
| 99 AsyncSocket::ConnState AsyncSocketAdapter::GetState() const { | |
| 100 return socket_->GetState(); | |
| 101 } | |
| 102 | |
| 103 int AsyncSocketAdapter::GetOption(Option opt, int* value) { | |
| 104 return socket_->GetOption(opt, value); | |
| 105 } | |
| 106 | |
| 107 int AsyncSocketAdapter::SetOption(Option opt, int value) { | |
| 108 return socket_->SetOption(opt, value); | |
| 109 } | |
| 110 | |
| 111 void AsyncSocketAdapter::OnConnectEvent(AsyncSocket* socket) { | |
| 112 SignalConnectEvent(this); | |
| 113 } | |
| 114 | |
| 115 void AsyncSocketAdapter::OnReadEvent(AsyncSocket* socket) { | |
| 116 SignalReadEvent(this); | |
| 117 } | |
| 118 | |
| 119 void AsyncSocketAdapter::OnWriteEvent(AsyncSocket* socket) { | |
| 120 SignalWriteEvent(this); | |
| 121 } | |
| 122 | |
| 123 void AsyncSocketAdapter::OnCloseEvent(AsyncSocket* socket, int err) { | |
| 124 SignalCloseEvent(this, err); | |
| 125 } | |
| 126 | |
| 127 } // namespace rtc | |
| OLD | NEW |