| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_LINUX) | 10 #if defined(OS_LINUX) |
| 11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 26 // The socket's Read and Write methods may not be called until Connect | 26 // The socket's Read and Write methods may not be called until Connect |
| 27 // succeeds. | 27 // succeeds. |
| 28 // | 28 // |
| 29 // It is valid to call Connect on an already connected socket, in which case | 29 // It is valid to call Connect on an already connected socket, in which case |
| 30 // OK is simply returned. | 30 // OK is simply returned. |
| 31 // | 31 // |
| 32 // Connect may also be called again after a call to the Disconnect method. | 32 // Connect may also be called again after a call to the Disconnect method. |
| 33 // | 33 // |
| 34 virtual int Connect(CompletionCallback* callback) = 0; | 34 virtual int Connect(CompletionCallback* callback) = 0; |
| 35 | 35 |
| 36 // Called to disconnect a connected socket. Does nothing if the socket is | 36 // Called to disconnect a socket. Does nothing if the socket is already |
| 37 // already disconnected. After calling Disconnect it is possible to call | 37 // disconnected. After calling Disconnect it is possible to call Connect |
| 38 // Connect again to establish a new connection. | 38 // again to establish a new connection. |
| 39 // |
| 40 // If IO (Connect, Read, or Write) is pending when the socket is |
| 41 // disconnected, the pending IO is cancelled, and the completion callback |
| 42 // will not be called. |
| 39 virtual void Disconnect() = 0; | 43 virtual void Disconnect() = 0; |
| 40 | 44 |
| 41 // Called to test if the connection is still alive. Returns false if a | 45 // Called to test if the connection is still alive. Returns false if a |
| 42 // connection wasn't established or the connection is dead. | 46 // connection wasn't established or the connection is dead. |
| 43 virtual bool IsConnected() const = 0; | 47 virtual bool IsConnected() const = 0; |
| 44 | 48 |
| 45 // Called to test if the connection is still alive and idle. Returns false | 49 // Called to test if the connection is still alive and idle. Returns false |
| 46 // if a connection wasn't established, the connection is dead, or some data | 50 // if a connection wasn't established, the connection is dead, or some data |
| 47 // have been received. | 51 // have been received. |
| 48 virtual bool IsConnectedAndIdle() const = 0; | 52 virtual bool IsConnectedAndIdle() const = 0; |
| 49 | 53 |
| 50 #if defined(OS_LINUX) | 54 #if defined(OS_LINUX) |
| 51 // Identical to posix system call getpeername(). | 55 // Identical to posix system call getpeername(). |
| 52 // Needed by ssl_client_socket_nss. | 56 // Needed by ssl_client_socket_nss. |
| 53 virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen); | 57 virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen); |
| 54 #endif | 58 #endif |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 } // namespace net | 61 } // namespace net |
| 58 | 62 |
| 59 #endif // NET_SOCKET_CLIENT_SOCKET_H_ | 63 #endif // NET_SOCKET_CLIENT_SOCKET_H_ |
| OLD | NEW |