Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: net/socket/tcp_server_socket_libevent.h

Issue 10907154: Allow server sockets to rebind to same port if there is nothing actively listening on that port. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_TCP_SERVER_SOCKET_LIBEVENT_H_ 5 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_
6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ 6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
(...skipping 17 matching lines...) Expand all
28 // net::ServerSocket implementation. 28 // net::ServerSocket implementation.
29 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE; 29 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE;
30 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; 30 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
31 virtual int Accept(scoped_ptr<StreamSocket>* socket, 31 virtual int Accept(scoped_ptr<StreamSocket>* socket,
32 const CompletionCallback& callback) OVERRIDE; 32 const CompletionCallback& callback) OVERRIDE;
33 33
34 // MessageLoopForIO::Watcher implementation. 34 // MessageLoopForIO::Watcher implementation.
35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
37 37
38 // Sets corresponding flags in |socket_options_| to allow the socket
39 // to share the local address to which the socket will be bound with
40 // other processes. Should be called before Bind().
41 void AllowAddressReuse();
42
38 private: 43 private:
39 int AcceptInternal(scoped_ptr<StreamSocket>* socket); 44 int AcceptInternal(scoped_ptr<StreamSocket>* socket);
40 void Close(); 45 void Close();
41 46
47 enum SocketOptions {
Sergey Ulanov 2012/09/12 19:38:24 types must be defined before methods.
justinlin 2012/09/12 21:11:00 Ack.
48 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0,
49 };
50
51 // Applies |socket_options_| to |socket_|. Should be called before
52 // Bind().
53 int SetSocketOptions();
54
42 int socket_; 55 int socket_;
43 56
57 // Bitwise-or'd combination of SocketOptions. Specifies the set of
58 // options that should be applied to |socket_| before Bind().
59 int socket_options_;
Sergey Ulanov 2012/09/12 19:38:24 Do we really need these options to be bit flags? i
Sergey Ulanov 2012/09/12 19:38:24 You need to initialize this variable in the constr
justinlin 2012/09/12 21:11:00 Done.
justinlin 2012/09/12 21:11:00 Done.
60
44 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; 61 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_;
45 62
46 scoped_ptr<StreamSocket>* accept_socket_; 63 scoped_ptr<StreamSocket>* accept_socket_;
47 CompletionCallback accept_callback_; 64 CompletionCallback accept_callback_;
48 65
49 BoundNetLog net_log_; 66 BoundNetLog net_log_;
50 }; 67 };
51 68
52 } // namespace net 69 } // namespace net
53 70
54 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ 71 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_
OLDNEW
« no previous file with comments | « no previous file | net/socket/tcp_server_socket_libevent.cc » ('j') | net/socket/tcp_server_socket_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698