| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright (c) 2006-2008 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 NET_BASE_CLIENT_SOCKET_H_ |  | 
| 6 #define NET_BASE_CLIENT_SOCKET_H_ |  | 
| 7 |  | 
| 8 #include "build/build_config.h" |  | 
| 9 |  | 
| 10 #if defined(OS_LINUX) |  | 
| 11 #include <sys/socket.h> |  | 
| 12 #endif |  | 
| 13 |  | 
| 14 #include "net/base/socket.h" |  | 
| 15 |  | 
| 16 namespace net { |  | 
| 17 |  | 
| 18 class ClientSocket : public Socket { |  | 
| 19  public: |  | 
| 20   // Called to establish a connection.  Returns OK if the connection could be |  | 
| 21   // established synchronously.  Otherwise, ERR_IO_PENDING is returned and the |  | 
| 22   // given callback will run asynchronously when the connection is established |  | 
| 23   // or when an error occurs.  The result is some other error code if the |  | 
| 24   // connection could not be established. |  | 
| 25   // |  | 
| 26   // The socket's Read and Write methods may not be called until Connect |  | 
| 27   // succeeds. |  | 
| 28   // |  | 
| 29   // It is valid to call Connect on an already connected socket, in which case |  | 
| 30   // OK is simply returned. |  | 
| 31   // |  | 
| 32   // Connect may also be called again after a call to the Disconnect method. |  | 
| 33   // |  | 
| 34   virtual int Connect(CompletionCallback* callback) = 0; |  | 
| 35 |  | 
| 36   // Called to disconnect a connected socket.  Does nothing if the socket is |  | 
| 37   // already disconnected.  After calling Disconnect it is possible to call |  | 
| 38   // Connect again to establish a new connection. |  | 
| 39   virtual void Disconnect() = 0; |  | 
| 40 |  | 
| 41   // Called to test if the connection is still alive.  Returns false if a |  | 
| 42   // connection wasn't established or the connection is dead. |  | 
| 43   virtual bool IsConnected() const = 0; |  | 
| 44 |  | 
| 45   // 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 |  | 
| 47   // have been received. |  | 
| 48   virtual bool IsConnectedAndIdle() const = 0; |  | 
| 49 |  | 
| 50 #if defined(OS_LINUX) |  | 
| 51   // Identical to posix system call getpeername(). |  | 
| 52   // Needed by ssl_client_socket_nss. |  | 
| 53   virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen); |  | 
| 54 #endif |  | 
| 55 }; |  | 
| 56 |  | 
| 57 }  // namespace net |  | 
| 58 |  | 
| 59 #endif  // NET_BASE_CLIENT_SOCKET_H_ |  | 
| OLD | NEW | 
|---|