OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Stream-based listen socket implementation that handles reading and writing | 5 // Stream-based listen socket implementation that handles reading and writing |
6 // to the socket, but does not handle creating the socket nor connecting | 6 // to the socket, but does not handle creating the socket nor connecting |
7 // sockets, which are handled by subclasses on creation and in Accept, | 7 // sockets, which are handled by subclasses on creation and in Accept, |
8 // respectively. | 8 // respectively. |
9 | 9 |
10 // StreamListenSocket handles IO asynchronously in the specified MessageLoop. | 10 // StreamListenSocket handles IO asynchronously in the specified MessageLoop. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 protected: | 66 protected: |
67 virtual ~Delegate() {} | 67 virtual ~Delegate() {} |
68 }; | 68 }; |
69 | 69 |
70 // Send data to the socket. | 70 // Send data to the socket. |
71 void Send(const char* bytes, int len, bool append_linefeed = false); | 71 void Send(const char* bytes, int len, bool append_linefeed = false); |
72 void Send(const std::string& str, bool append_linefeed = false); | 72 void Send(const std::string& str, bool append_linefeed = false); |
73 | 73 |
74 // Copies the local address to |address|. Returns a network error code. | 74 // Copies the local address to |address|. Returns a network error code. |
75 int GetLocalAddress(IPEndPoint* address); | 75 int GetLocalAddress(IPEndPoint* address); |
| 76 // Copies the peer address to |address|. Returns a network error code. |
| 77 int GetPeerAddress(IPEndPoint* address); |
76 | 78 |
77 static const int kSocketError; | 79 static const int kSocketError; |
78 | 80 |
79 protected: | 81 protected: |
80 enum WaitState { | 82 enum WaitState { |
81 NOT_WAITING = 0, | 83 NOT_WAITING = 0, |
82 WAITING_ACCEPT = 1, | 84 WAITING_ACCEPT = 1, |
83 WAITING_READ = 2 | 85 WAITING_READ = 2 |
84 }; | 86 }; |
85 | 87 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual ~StreamListenSocketFactory() {} | 141 virtual ~StreamListenSocketFactory() {} |
140 | 142 |
141 // Returns a new instance of StreamListenSocket or NULL if an error occurred. | 143 // Returns a new instance of StreamListenSocket or NULL if an error occurred. |
142 virtual scoped_ptr<StreamListenSocket> CreateAndListen( | 144 virtual scoped_ptr<StreamListenSocket> CreateAndListen( |
143 StreamListenSocket::Delegate* delegate) const = 0; | 145 StreamListenSocket::Delegate* delegate) const = 0; |
144 }; | 146 }; |
145 | 147 |
146 } // namespace net | 148 } // namespace net |
147 | 149 |
148 #endif // NET_SOCKET_STREAM_LISTEN_SOCKET_H_ | 150 #endif // NET_SOCKET_STREAM_LISTEN_SOCKET_H_ |
OLD | NEW |