From 03ec25380e837518ede1b03d9a05669e9bc1746c Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Fri, 27 May 2011 21:50:28 +0000 Subject: Bind() methods for TCP sockets BUG=80245 TEST=None Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=87077 Review URL: http://codereview.chromium.org/7004055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87095 0039d316-1c4b-4281-b951-d872f2087c98 --- net/socket/tcp_client_socket_libevent.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'net/socket/tcp_client_socket_libevent.h') diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h index 45f24c2..b9bc557 100644 --- a/net/socket/tcp_client_socket_libevent.h +++ b/net/socket/tcp_client_socket_libevent.h @@ -38,7 +38,10 @@ class TCPClientSocketLibevent : public StreamSocket, base::NonThreadSafe { // the given socket and then acts as if Connect() had been called. This // function is used by TCPServerSocket() to adopt accepted connections // and for testing. - void AdoptSocket(int socket); + int AdoptSocket(int socket); + + // Binds the socket to a local IP address and port. + int Bind(const IPEndPoint& address); // StreamSocket methods: virtual int Connect(CompletionCallback* callback); @@ -130,12 +133,6 @@ class TCPClientSocketLibevent : public StreamSocket, base::NonThreadSafe { return next_connect_state_ != CONNECT_STATE_NONE; } - // Returns the OS error code (or 0 on success). - int CreateSocket(const struct addrinfo* ai); - - // Returns the OS error code (or 0 on success). - int SetupSocket(); - // Helper to add a TCP_CONNECT (end) event to the NetLog. void LogConnectCompletion(int net_error); @@ -144,6 +141,13 @@ class TCPClientSocketLibevent : public StreamSocket, base::NonThreadSafe { int socket_; + // Local IP address and port we are bound to. Set to NULL if Bind() + // was't called (in that cases OS chooses address/port). + scoped_ptr bind_address_; + + // Stores bound socket between Bind() and Connect() calls. + int bound_socket_; + // The list of addresses we should try in order to establish a connection. AddressList addresses_; -- cgit v1.1