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

Unified Diff: net/udp/udp_socket_libevent.h

Issue 721273002: Remove timing limitation to set Broadcast, ReceiveBuffer, and SendBuffer options from UDPSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: net/udp/udp_socket_libevent.h
diff --git a/net/udp/udp_socket_libevent.h b/net/udp/udp_socket_libevent.h
index 2ac564debc533752d038b81a9b76312ecf0cc920..6c9feff2ee1a97a3dfe37e89bebb8587ec5fac00 100644
--- a/net/udp/udp_socket_libevent.h
+++ b/net/udp/udp_socket_libevent.h
@@ -28,12 +28,17 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe {
const net::NetLog::Source& source);
virtual ~UDPSocketLibevent();
+ // Opens the socket.
+ // Returns a net error code.
+ int Open(AddressFamily address_family);
+
// Connect the socket to connect with a certain |address|.
+ // Should be called after Open().
rvargas (doing something else) 2014/12/02 23:28:09 The comments should be the same for both implement
hidehiko 2014/12/03 17:33:27 Done.
// Returns a net error code.
int Connect(const IPEndPoint& address);
// Bind the address/port for this socket to |address|. This is generally
- // only used on a server.
+ // only used on a server. Should be called after Open().
// Returns a net error code.
int Bind(const IPEndPoint& address);
@@ -94,13 +99,15 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe {
const CompletionCallback& callback);
// Set the receive buffer size (in bytes) for the socket.
+ // Returns a network error code.
int SetReceiveBufferSize(int32 size);
// Set the send buffer size (in bytes) for the socket.
+ // Returns a network error code.
int SetSendBufferSize(int32 size);
// Returns true if the socket is already connected or bound.
- bool is_connected() const { return socket_ != kInvalidSocket; }
+ bool is_connected() const { return is_connected_; }
const BoundNetLog& NetLog() const { return net_log_; }
@@ -109,10 +116,10 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe {
// other processes. Should be called before Bind().
void AllowAddressReuse();
- // Sets corresponding flags in |socket_options_| to allow sending
- // and receiving packets to and from broadcast addresses. Should be
- // called before Bind().
- void AllowBroadcast();
+ // Sets corresponding flags in |socket_options_| to allow or disallow sending
+ // and receiving packets to and from broadcast addresses.
+ // Returns a network error code.
+ int SetBroadcast(bool broadcast);
// Join the multicast group.
// |group_address| is the group address to join, could be either
@@ -169,8 +176,7 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe {
private:
enum SocketOptions {
SOCKET_OPTION_REUSE_ADDRESS = 1 << 0,
- SOCKET_OPTION_BROADCAST = 1 << 1,
- SOCKET_OPTION_MULTICAST_LOOP = 1 << 2
+ SOCKET_OPTION_MULTICAST_LOOP = 1 << 1
};
class ReadWatcher : public base::MessageLoopForIO::Watcher {
@@ -218,7 +224,7 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe {
const sockaddr* addr) const;
void LogWrite(int result, const char* bytes, const IPEndPoint* address) const;
- // Returns the OS error code (or 0 on success).
+ // Returns a network error code.
rvargas (doing something else) 2014/12/02 23:28:09 nit: network -> net
hidehiko 2014/12/03 17:33:27 Done.
int CreateSocket(int addr_family);
// Same as SendTo(), except that address is passed by pointer
@@ -242,6 +248,7 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe {
int socket_;
int addr_family_;
+ bool is_connected_;
// Bitwise-or'd combination of SocketOptions. Specifies the set of
// options that should be applied to |socket_| before Bind().

Powered by Google App Engine
This is Rietveld 408576698