OLD | NEW |
(Empty) | |
| 1 // Copyright 2004 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBRTC_LIBJINGLE_XMPP_ASYNCSOCKET_H_ |
| 6 #define WEBRTC_LIBJINGLE_XMPP_ASYNCSOCKET_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "webrtc/base/sigslot.h" |
| 11 |
| 12 namespace rtc { |
| 13 class SocketAddress; |
| 14 } |
| 15 |
| 16 namespace buzz { |
| 17 |
| 18 class AsyncSocket { |
| 19 public: |
| 20 enum State { |
| 21 STATE_CLOSED = 0, //!< Socket is not open. |
| 22 STATE_CLOSING, //!< Socket is closing but can have buffered data |
| 23 STATE_CONNECTING, //!< In the process of |
| 24 STATE_OPEN, //!< Socket is connected |
| 25 #if defined(FEATURE_ENABLE_SSL) |
| 26 STATE_TLS_CONNECTING, //!< Establishing TLS connection |
| 27 STATE_TLS_OPEN, //!< TLS connected |
| 28 #endif |
| 29 }; |
| 30 |
| 31 enum Error { |
| 32 ERROR_NONE = 0, //!< No error |
| 33 ERROR_WINSOCK, //!< Winsock error |
| 34 ERROR_DNS, //!< Couldn't resolve host name |
| 35 ERROR_WRONGSTATE, //!< Call made while socket is in the wrong state |
| 36 #if defined(FEATURE_ENABLE_SSL) |
| 37 ERROR_SSL, //!< Something went wrong with OpenSSL |
| 38 #endif |
| 39 }; |
| 40 |
| 41 virtual ~AsyncSocket() {} |
| 42 virtual State state() = 0; |
| 43 virtual Error error() = 0; |
| 44 virtual int GetError() = 0; // winsock error code |
| 45 |
| 46 virtual bool Connect(const rtc::SocketAddress& addr) = 0; |
| 47 virtual bool Read(char * data, size_t len, size_t* len_read) = 0; |
| 48 virtual bool Write(const char * data, size_t len) = 0; |
| 49 virtual bool Close() = 0; |
| 50 #if defined(FEATURE_ENABLE_SSL) |
| 51 // We allow matching any passed domain. This allows us to avoid |
| 52 // handling the valuable certificates for logins into proxies. If |
| 53 // both names are passed as empty, we do not require a match. |
| 54 virtual bool StartTls(const std::string & domainname) = 0; |
| 55 #endif |
| 56 |
| 57 sigslot::signal0<> SignalConnected; |
| 58 sigslot::signal0<> SignalSSLConnected; |
| 59 sigslot::signal0<> SignalClosed; |
| 60 sigslot::signal0<> SignalRead; |
| 61 sigslot::signal0<> SignalError; |
| 62 }; |
| 63 |
| 64 } |
| 65 |
| 66 #endif // WEBRTC_LIBJINGLE_XMPP_ASYNCSOCKET_H_ |
OLD | NEW |