Fix mouse warp with 2x displays
[chromium-blink-merge.git] / net / udp / udp_server_socket.cc
blob9fc92df0659e4a6a3487fb5ab387c9ea05d653e3
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.
5 #include "net/udp/udp_server_socket.h"
7 #include "net/base/net_errors.h"
8 #include "net/base/rand_callback.h"
10 namespace net {
12 UDPServerSocket::UDPServerSocket(net::NetLog* net_log,
13 const net::NetLog::Source& source)
14 : socket_(DatagramSocket::DEFAULT_BIND,
15 RandIntCallback(),
16 net_log,
17 source),
18 allow_address_reuse_(false),
19 allow_broadcast_(false) {
22 UDPServerSocket::~UDPServerSocket() {
25 int UDPServerSocket::Listen(const IPEndPoint& address) {
26 int rv = socket_.Open(address.GetFamily());
27 if (rv != OK)
28 return rv;
30 if (allow_address_reuse_) {
31 rv = socket_.AllowAddressReuse();
32 if (rv != OK) {
33 socket_.Close();
34 return rv;
38 if (allow_broadcast_) {
39 rv = socket_.SetBroadcast(true);
40 if (rv != OK) {
41 socket_.Close();
42 return rv;
46 return socket_.Bind(address);
49 int UDPServerSocket::RecvFrom(IOBuffer* buf,
50 int buf_len,
51 IPEndPoint* address,
52 const CompletionCallback& callback) {
53 return socket_.RecvFrom(buf, buf_len, address, callback);
56 int UDPServerSocket::SendTo(IOBuffer* buf,
57 int buf_len,
58 const IPEndPoint& address,
59 const CompletionCallback& callback) {
60 return socket_.SendTo(buf, buf_len, address, callback);
63 int UDPServerSocket::SetReceiveBufferSize(int32 size) {
64 return socket_.SetReceiveBufferSize(size);
67 int UDPServerSocket::SetSendBufferSize(int32 size) {
68 return socket_.SetSendBufferSize(size);
71 void UDPServerSocket::Close() {
72 socket_.Close();
75 int UDPServerSocket::GetPeerAddress(IPEndPoint* address) const {
76 return socket_.GetPeerAddress(address);
79 int UDPServerSocket::GetLocalAddress(IPEndPoint* address) const {
80 return socket_.GetLocalAddress(address);
83 const BoundNetLog& UDPServerSocket::NetLog() const {
84 return socket_.NetLog();
87 void UDPServerSocket::AllowAddressReuse() {
88 allow_address_reuse_ = true;
91 void UDPServerSocket::AllowBroadcast() {
92 allow_broadcast_ = true;
95 int UDPServerSocket::JoinGroup(const IPAddressNumber& group_address) const {
96 return socket_.JoinGroup(group_address);
99 int UDPServerSocket::LeaveGroup(const IPAddressNumber& group_address) const {
100 return socket_.LeaveGroup(group_address);
103 int UDPServerSocket::SetMulticastInterface(uint32 interface_index) {
104 return socket_.SetMulticastInterface(interface_index);
107 int UDPServerSocket::SetMulticastTimeToLive(int time_to_live) {
108 return socket_.SetMulticastTimeToLive(time_to_live);
111 int UDPServerSocket::SetMulticastLoopbackMode(bool loopback) {
112 return socket_.SetMulticastLoopbackMode(loopback);
115 int UDPServerSocket::SetDiffServCodePoint(DiffServCodePoint dscp) {
116 return socket_.SetDiffServCodePoint(dscp);
119 void UDPServerSocket::DetachFromThread() {
120 socket_.DetachFromThread();
123 #if defined(OS_WIN)
124 void UDPServerSocket::UseNonBlockingIO() {
125 socket_.UseNonBlockingIO();
127 #endif
129 } // namespace net