OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #ifndef NET_SOCKET_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_H_ |
6 #define NET_SOCKET_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_H_ |
7 | 7 |
8 #include "build/build_config.h" | |
9 | |
10 // For struct sockaddr and socklen_t. | |
11 #if defined(OS_POSIX) | |
12 #include <sys/types.h> | |
13 #include <sys/socket.h> | |
14 #elif defined(OS_WIN) | |
15 #include <ws2tcpip.h> | |
16 #endif | |
17 | |
18 #include "net/socket/socket.h" | 8 #include "net/socket/socket.h" |
19 | 9 |
20 namespace net { | 10 namespace net { |
21 | 11 |
| 12 class AddressList; |
22 class LoadLog; | 13 class LoadLog; |
23 | 14 |
24 class ClientSocket : public Socket { | 15 class ClientSocket : public Socket { |
25 public: | 16 public: |
26 // Called to establish a connection. Returns OK if the connection could be | 17 // Called to establish a connection. Returns OK if the connection could be |
27 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the | 18 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the |
28 // given callback will run asynchronously when the connection is established | 19 // given callback will run asynchronously when the connection is established |
29 // or when an error occurs. The result is some other error code if the | 20 // or when an error occurs. The result is some other error code if the |
30 // connection could not be established. | 21 // connection could not be established. |
31 // | 22 // |
(...skipping 18 matching lines...) Expand all Loading... |
50 | 41 |
51 // Called to test if the connection is still alive. Returns false if a | 42 // Called to test if the connection is still alive. Returns false if a |
52 // connection wasn't established or the connection is dead. | 43 // connection wasn't established or the connection is dead. |
53 virtual bool IsConnected() const = 0; | 44 virtual bool IsConnected() const = 0; |
54 | 45 |
55 // Called to test if the connection is still alive and idle. Returns false | 46 // Called to test if the connection is still alive and idle. Returns false |
56 // if a connection wasn't established, the connection is dead, or some data | 47 // if a connection wasn't established, the connection is dead, or some data |
57 // have been received. | 48 // have been received. |
58 virtual bool IsConnectedAndIdle() const = 0; | 49 virtual bool IsConnectedAndIdle() const = 0; |
59 | 50 |
60 // Identical to BSD socket call getpeername(). | 51 // Copies the peer address to |address| and returns a network error code. |
61 // Needed by ssl_client_socket_nss and ssl_client_socket_mac. | 52 virtual int GetPeerAddress(AddressList* address) const = 0; |
62 virtual int GetPeerName(struct sockaddr* name, socklen_t* namelen) = 0; | |
63 }; | 53 }; |
64 | 54 |
65 } // namespace net | 55 } // namespace net |
66 | 56 |
67 #endif // NET_SOCKET_CLIENT_SOCKET_H_ | 57 #endif // NET_SOCKET_CLIENT_SOCKET_H_ |
OLD | NEW |