13ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// Copyright (c) 2011 The Chromium Authors. All rights reserved.
21e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block// Use of this source code is governed by a BSD-style license that can be
31e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block// found in the LICENSE file.
41e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
51e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block#include "net/udp/udp_client_socket.h"
61e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
71e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block#include "net/base/net_log.h"
81e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
91e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blocknamespace net {
101e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
111e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockUDPClientSocket::UDPClientSocket(DatagramSocket::BindType bind_type,
121e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block                                 const RandIntCallback& rand_int_cb,
131e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block                                 net::NetLog* net_log,
141e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block                                 const net::NetLog::Source& source)
151e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block    : socket_(bind_type, rand_int_cb, net_log, source) {
161e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block}
171e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
181e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockUDPClientSocket::~UDPClientSocket() {
191e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block}
201e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
211e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockint UDPClientSocket::Connect(const IPEndPoint& address) {
221e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  return socket_.Connect(address);
231e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block}
241e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
251e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockint UDPClientSocket::Read(IOBuffer* buf,
261e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block                          int buf_len,
271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block                          const CompletionCallback& callback) {
283ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.Read(buf, buf_len, callback);
29592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch}
303ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
313ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochint UDPClientSocket::Write(IOBuffer* buf,
323ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                          int buf_len,
333ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                          const CompletionCallback& callback) {
343ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.Write(buf, buf_len, callback);
3585b71799222b55eb5dd74ea26efe0c64ab655c8cBen Murdoch}
363ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
373ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid UDPClientSocket::Close() {
38592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch  socket_.Close();
3985b71799222b55eb5dd74ea26efe0c64ab655c8cBen Murdoch}
4085b71799222b55eb5dd74ea26efe0c64ab655c8cBen Murdoch
41592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdochint UDPClientSocket::GetPeerAddress(IPEndPoint* address) const {
423ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.GetPeerAddress(address);
433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch}
443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
453ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochint UDPClientSocket::GetLocalAddress(IPEndPoint* address) const {
463ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.GetLocalAddress(address);
473ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch}
4885b71799222b55eb5dd74ea26efe0c64ab655c8cBen Murdoch
493ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochbool UDPClientSocket::SetReceiveBufferSize(int32 size) {
503ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.SetReceiveBufferSize(size);
513ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch}
523ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
533ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochbool UDPClientSocket::SetSendBufferSize(int32 size) {
543ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.SetSendBufferSize(size);
553ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch}
563ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst BoundNetLog& UDPClientSocket::NetLog() const {
583ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  return socket_.NetLog();
593ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch}
603ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch}  // namespace net
623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch