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

Side by Side Diff: net/udp/udp_socket_libevent.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/base/net_errors_win.cc ('k') | net/udp/udp_socket_win.cc » ('j') | 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_libevent.h" 5 #include "net/udp/udp_socket_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 515 }
516 if (rv < 0) 516 if (rv < 0)
517 return MapSystemError(errno); 517 return MapSystemError(errno);
518 } 518 }
519 return OK; 519 return OK;
520 } 520 }
521 521
522 int UDPSocketLibevent::DoBind(const IPEndPoint& address) { 522 int UDPSocketLibevent::DoBind(const IPEndPoint& address) {
523 SockaddrStorage storage; 523 SockaddrStorage storage;
524 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) 524 if (!address.ToSockAddr(storage.addr, &storage.addr_len))
525 return ERR_UNEXPECTED; 525 return ERR_ADDRESS_INVALID;
526 int rv = bind(socket_, storage.addr, storage.addr_len); 526 int rv = bind(socket_, storage.addr, storage.addr_len);
527 return rv < 0 ? MapSystemError(errno) : rv; 527 return rv < 0 ? MapSystemError(errno) : rv;
528 } 528 }
529 529
530 int UDPSocketLibevent::RandomBind(const IPEndPoint& address) { 530 int UDPSocketLibevent::RandomBind(const IPEndPoint& address) {
531 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); 531 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null());
532 532
533 // Construct IPAddressNumber of appropriate size (IPv4 or IPv6) of 0s. 533 // Construct IPAddressNumber of appropriate size (IPv4 or IPv6) of 0s.
534 IPAddressNumber ip(address.address().size()); 534 IPAddressNumber ip(address.address().size());
535 535
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 610 }
611 default: 611 default:
612 NOTREACHED() << "Invalid address family"; 612 NOTREACHED() << "Invalid address family";
613 return ERR_ADDRESS_INVALID; 613 return ERR_ADDRESS_INVALID;
614 } 614 }
615 } 615 }
616 616
617 int UDPSocketLibevent::SetMulticastTimeToLive(int time_to_live) { 617 int UDPSocketLibevent::SetMulticastTimeToLive(int time_to_live) {
618 DCHECK(CalledOnValidThread()); 618 DCHECK(CalledOnValidThread());
619 if (is_connected()) 619 if (is_connected())
620 return ERR_UNEXPECTED; 620 return ERR_SOCKET_IS_CONNECTED;
621 621
622 if (time_to_live < 0 || time_to_live > 255) 622 if (time_to_live < 0 || time_to_live > 255)
623 return ERR_INVALID_ARGUMENT; 623 return ERR_INVALID_ARGUMENT;
624 multicast_time_to_live_ = time_to_live; 624 multicast_time_to_live_ = time_to_live;
625 return OK; 625 return OK;
626 } 626 }
627 627
628 int UDPSocketLibevent::SetMulticastLoopbackMode(bool loopback) { 628 int UDPSocketLibevent::SetMulticastLoopbackMode(bool loopback) {
629 DCHECK(CalledOnValidThread()); 629 DCHECK(CalledOnValidThread());
630 if (is_connected()) 630 if (is_connected())
631 return ERR_UNEXPECTED; 631 return ERR_SOCKET_IS_CONNECTED;
632 632
633 if (loopback) 633 if (loopback)
634 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; 634 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP;
635 else 635 else
636 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; 636 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP;
637 return OK; 637 return OK;
638 } 638 }
639 } // namespace net 639 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_errors_win.cc ('k') | net/udp/udp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698