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

Side by Side Diff: net/udp/datagram_server_socket.h

Issue 2508593002: net: move udp directory into socket (Closed)
Patch Set: revert sys/socket.h change Created 4 years, 1 month 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
« no previous file with comments | « net/udp/datagram_client_socket.h ('k') | net/udp/datagram_socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_UDP_DATAGRAM_SERVER_SOCKET_H_
6 #define NET_UDP_DATAGRAM_SERVER_SOCKET_H_
7
8 #include <stdint.h>
9
10 #include "net/base/completion_callback.h"
11 #include "net/base/net_export.h"
12 #include "net/udp/datagram_socket.h"
13 #include "net/udp/diff_serv_code_point.h"
14
15 namespace net {
16
17 class IPAddress;
18 class IPEndPoint;
19 class IOBuffer;
20
21 // A UDP Socket.
22 class NET_EXPORT DatagramServerSocket : public DatagramSocket {
23 public:
24 ~DatagramServerSocket() override {}
25
26 // Initialize this socket as a server socket listening at |address|.
27 // Returns a network error code.
28 virtual int Listen(const IPEndPoint& address) = 0;
29
30 // Read from a socket and receive sender address information.
31 // |buf| is the buffer to read data into.
32 // |buf_len| is the maximum amount of data to read.
33 // |address| is a buffer provided by the caller for receiving the sender
34 // address information about the received data. This buffer must be kept
35 // alive by the caller until the callback is placed.
36 // |callback| is the callback on completion of the RecvFrom.
37 // Returns a net error code, or ERR_IO_PENDING if the IO is in progress.
38 // If ERR_IO_PENDING is returned, the caller must keep |buf| and |address|
39 // alive until the callback is called.
40 virtual int RecvFrom(IOBuffer* buf,
41 int buf_len,
42 IPEndPoint* address,
43 const CompletionCallback& callback) = 0;
44
45 // Send to a socket with a particular destination.
46 // |buf| is the buffer to send.
47 // |buf_len| is the number of bytes to send.
48 // |address| is the recipient address.
49 // |callback| is the user callback function to call on complete.
50 // Returns a net error code, or ERR_IO_PENDING if the IO is in progress.
51 // If ERR_IO_PENDING is returned, the caller must keep |buf| and |address|
52 // alive until the callback is called.
53 virtual int SendTo(IOBuffer* buf,
54 int buf_len,
55 const IPEndPoint& address,
56 const CompletionCallback& callback) = 0;
57
58 // Set the receive buffer size (in bytes) for the socket.
59 // Returns a net error code.
60 virtual int SetReceiveBufferSize(int32_t size) = 0;
61
62 // Set the send buffer size (in bytes) for the socket.
63 // Returns a net error code.
64 virtual int SetSendBufferSize(int32_t size) = 0;
65
66 // Allow the socket to share the local address to which the socket will
67 // be bound with other processes. Should be called before Listen().
68 virtual void AllowAddressReuse() = 0;
69
70 // Allow sending and receiving packets to and from broadcast addresses.
71 // Should be called before Listen().
72 virtual void AllowBroadcast() = 0;
73
74 // Join the multicast group with address |group_address|.
75 // Returns a network error code.
76 virtual int JoinGroup(const IPAddress& group_address) const = 0;
77
78 // Leave the multicast group with address |group_address|.
79 // If the socket hasn't joined the group, it will be ignored.
80 // It's optional to leave the multicast group before destroying
81 // the socket. It will be done by the OS.
82 // Returns a network error code.
83 virtual int LeaveGroup(const IPAddress& group_address) const = 0;
84
85 // Set interface to use for multicast. If |interface_index| set to 0, default
86 // interface is used.
87 // Should be called before Bind().
88 // Returns a network error code.
89 virtual int SetMulticastInterface(uint32_t interface_index) = 0;
90
91 // Set the time-to-live option for UDP packets sent to the multicast
92 // group address. The default value of this option is 1.
93 // Cannot be negative or more than 255.
94 // Should be called before Bind().
95 // Returns a network error code.
96 virtual int SetMulticastTimeToLive(int time_to_live) = 0;
97
98 // Set the loopback flag for UDP socket. If this flag is true, the host
99 // will receive packets sent to the joined group from itself.
100 // The default value of this option is true.
101 // Should be called before Bind().
102 // Returns a network error code.
103 virtual int SetMulticastLoopbackMode(bool loopback) = 0;
104
105 // Set the Differentiated Services Code Point. May do nothing on
106 // some platforms. Returns a network error code.
107 virtual int SetDiffServCodePoint(DiffServCodePoint dscp) = 0;
108
109 // Resets the thread to be used for thread-safety checks.
110 virtual void DetachFromThread() = 0;
111 };
112
113 } // namespace net
114
115 #endif // NET_UDP_DATAGRAM_SERVER_SOCKET_H_
OLDNEW
« no previous file with comments | « net/udp/datagram_client_socket.h ('k') | net/udp/datagram_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698