summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket.h
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 23:26:44 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 23:26:44 +0000
commitf7984fc67f3c88b6ff1c738700a8229f387d732d (patch)
tree094f6be7633d60b0413370462bf6bd04b906ac00 /net/socket/client_socket.h
parent8c1be4e0311d52f07fe16fc091862957757dc002 (diff)
downloadchromium_src-f7984fc67f3c88b6ff1c738700a8229f387d732d.zip
chromium_src-f7984fc67f3c88b6ff1c738700a8229f387d732d.tar.gz
chromium_src-f7984fc67f3c88b6ff1c738700a8229f387d732d.tar.bz2
Move socket related files from net/base to net/socket.
Review URL: http://codereview.chromium.org/144009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket.h')
-rw-r--r--net/socket/client_socket.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h
new file mode 100644
index 0000000..54866b8
--- /dev/null
+++ b/net/socket/client_socket.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_SOCKET_CLIENT_SOCKET_H_
+#define NET_SOCKET_CLIENT_SOCKET_H_
+
+#include "build/build_config.h"
+
+#if defined(OS_LINUX)
+#include <sys/socket.h>
+#endif
+
+#include "net/socket/socket.h"
+
+namespace net {
+
+class ClientSocket : public Socket {
+ public:
+ // Called to establish a connection. Returns OK if the connection could be
+ // established synchronously. Otherwise, ERR_IO_PENDING is returned and the
+ // given callback will run asynchronously when the connection is established
+ // or when an error occurs. The result is some other error code if the
+ // connection could not be established.
+ //
+ // The socket's Read and Write methods may not be called until Connect
+ // succeeds.
+ //
+ // It is valid to call Connect on an already connected socket, in which case
+ // OK is simply returned.
+ //
+ // Connect may also be called again after a call to the Disconnect method.
+ //
+ virtual int Connect(CompletionCallback* callback) = 0;
+
+ // Called to disconnect a connected socket. Does nothing if the socket is
+ // already disconnected. After calling Disconnect it is possible to call
+ // Connect again to establish a new connection.
+ virtual void Disconnect() = 0;
+
+ // Called to test if the connection is still alive. Returns false if a
+ // connection wasn't established or the connection is dead.
+ virtual bool IsConnected() const = 0;
+
+ // Called to test if the connection is still alive and idle. Returns false
+ // if a connection wasn't established, the connection is dead, or some data
+ // have been received.
+ virtual bool IsConnectedAndIdle() const = 0;
+
+#if defined(OS_LINUX)
+ // Identical to posix system call getpeername().
+ // Needed by ssl_client_socket_nss.
+ virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen);
+#endif
+};
+
+} // namespace net
+
+#endif // NET_SOCKET_CLIENT_SOCKET_H_