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

Side by Side Diff: net/udp/udp_socket_win.cc

Issue 14666002: Adding ERR_SOCKET_IS_CONNECTED. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to origin/master Created 7 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « net/udp/udp_socket_libevent.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/udp/udp_socket_win.h" 5 #include "net/udp/udp_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 reinterpret_cast<const char*>(&hops), sizeof(hops)); 608 reinterpret_cast<const char*>(&hops), sizeof(hops));
609 if (rv < 0) 609 if (rv < 0)
610 return MapSystemError(WSAGetLastError()); 610 return MapSystemError(WSAGetLastError());
611 } 611 }
612 return OK; 612 return OK;
613 } 613 }
614 614
615 int UDPSocketWin::DoBind(const IPEndPoint& address) { 615 int UDPSocketWin::DoBind(const IPEndPoint& address) {
616 SockaddrStorage storage; 616 SockaddrStorage storage;
617 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) 617 if (!address.ToSockAddr(storage.addr, &storage.addr_len))
618 return ERR_UNEXPECTED; 618 return ERR_ADDRESS_INVALID;
619 int rv = bind(socket_, storage.addr, storage.addr_len); 619 int rv = bind(socket_, storage.addr, storage.addr_len);
620 return rv < 0 ? MapSystemError(WSAGetLastError()) : rv; 620 return rv < 0 ? MapSystemError(WSAGetLastError()) : rv;
621 } 621 }
622 622
623 int UDPSocketWin::RandomBind(const IPEndPoint& address) { 623 int UDPSocketWin::RandomBind(const IPEndPoint& address) {
624 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); 624 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null());
625 625
626 // Construct IPAddressNumber of appropriate size (IPv4 or IPv6) of 0s. 626 // Construct IPAddressNumber of appropriate size (IPv4 or IPv6) of 0s.
627 IPAddressNumber ip(address.address().size()); 627 IPAddressNumber ip(address.address().size());
628 628
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 713 }
714 default: 714 default:
715 NOTREACHED() << "Invalid address family"; 715 NOTREACHED() << "Invalid address family";
716 return ERR_ADDRESS_INVALID; 716 return ERR_ADDRESS_INVALID;
717 } 717 }
718 } 718 }
719 719
720 int UDPSocketWin::SetMulticastTimeToLive(int time_to_live) { 720 int UDPSocketWin::SetMulticastTimeToLive(int time_to_live) {
721 DCHECK(CalledOnValidThread()); 721 DCHECK(CalledOnValidThread());
722 if (is_connected()) 722 if (is_connected())
723 return ERR_UNEXPECTED; 723 return ERR_SOCKET_IS_CONNECTED;
724 724
725 if (time_to_live < 0 || time_to_live > 255) 725 if (time_to_live < 0 || time_to_live > 255)
726 return ERR_INVALID_ARGUMENT; 726 return ERR_INVALID_ARGUMENT;
727 multicast_time_to_live_ = time_to_live; 727 multicast_time_to_live_ = time_to_live;
728 return OK; 728 return OK;
729 } 729 }
730 730
731 int UDPSocketWin::SetMulticastLoopbackMode(bool loopback) { 731 int UDPSocketWin::SetMulticastLoopbackMode(bool loopback) {
732 DCHECK(CalledOnValidThread()); 732 DCHECK(CalledOnValidThread());
733 if (is_connected()) 733 if (is_connected())
734 return ERR_UNEXPECTED; 734 return ERR_SOCKET_IS_CONNECTED;
735 735
736 if (loopback) 736 if (loopback)
737 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; 737 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP;
738 else 738 else
739 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; 739 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP;
740 return OK; 740 return OK;
741 } 741 }
742 742
743 } // namespace net 743 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698