Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / udp / udp_client_socket.cc
blob5b7639f0b82db32f5ca8b32851c91fc568192ae7
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
3 // found in the LICENSE file.
5 #include "net/udp/udp_client_socket.h"
7 #include "net/base/net_errors.h"
8 #include "net/log/net_log.h"
10 namespace net {
12 UDPClientSocket::UDPClientSocket(DatagramSocket::BindType bind_type,
13 const RandIntCallback& rand_int_cb,
14 net::NetLog* net_log,
15 const net::NetLog::Source& source)
16 : socket_(bind_type, rand_int_cb, net_log, source) {
19 UDPClientSocket::~UDPClientSocket() {
22 int UDPClientSocket::Connect(const IPEndPoint& address) {
23 int rv = socket_.Open(address.GetFamily());
24 if (rv != OK)
25 return rv;
26 return socket_.Connect(address);
29 int UDPClientSocket::Read(IOBuffer* buf,
30 int buf_len,
31 const CompletionCallback& callback) {
32 return socket_.Read(buf, buf_len, callback);
35 int UDPClientSocket::Write(IOBuffer* buf,
36 int buf_len,
37 const CompletionCallback& callback) {
38 return socket_.Write(buf, buf_len, callback);
41 void UDPClientSocket::Close() {
42 socket_.Close();
45 int UDPClientSocket::GetPeerAddress(IPEndPoint* address) const {
46 return socket_.GetPeerAddress(address);
49 int UDPClientSocket::GetLocalAddress(IPEndPoint* address) const {
50 return socket_.GetLocalAddress(address);
53 int UDPClientSocket::SetReceiveBufferSize(int32 size) {
54 return socket_.SetReceiveBufferSize(size);
57 int UDPClientSocket::SetSendBufferSize(int32 size) {
58 return socket_.SetSendBufferSize(size);
61 const BoundNetLog& UDPClientSocket::NetLog() const {
62 return socket_.NetLog();
65 #if defined(OS_WIN)
66 void UDPClientSocket::UseNonBlockingIO() {
67 socket_.UseNonBlockingIO();
69 #endif
71 } // namespace net