| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include "webrtc/base/physicalsocketserver.h" | 10 #include "webrtc/base/physicalsocketserver.h" |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 602 |
| 603 bool SocketDispatcher::Initialize() { | 603 bool SocketDispatcher::Initialize() { |
| 604 RTC_DCHECK(s_ != INVALID_SOCKET); | 604 RTC_DCHECK(s_ != INVALID_SOCKET); |
| 605 // Must be a non-blocking | 605 // Must be a non-blocking |
| 606 #if defined(WEBRTC_WIN) | 606 #if defined(WEBRTC_WIN) |
| 607 u_long argp = 1; | 607 u_long argp = 1; |
| 608 ioctlsocket(s_, FIONBIO, &argp); | 608 ioctlsocket(s_, FIONBIO, &argp); |
| 609 #elif defined(WEBRTC_POSIX) | 609 #elif defined(WEBRTC_POSIX) |
| 610 fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK); | 610 fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK); |
| 611 #endif | 611 #endif |
| 612 #if defined(WEBRTC_IOS) |
| 613 // iOS may kill sockets when the app is moved to the background |
| 614 // (specifically, if the app doesn't use the "voip" UIBackgroundMode). When |
| 615 // we attempt to write to such a socket, SIGPIPE will be raised, which by |
| 616 // default will terminate the process, which we don't want. By specifying |
| 617 // this socket option, SIGPIPE will be disabled for the socket. |
| 618 int value = 1; |
| 619 ::setsockopt(s_, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value)); |
| 620 #endif |
| 612 ss_->Add(this); | 621 ss_->Add(this); |
| 613 return true; | 622 return true; |
| 614 } | 623 } |
| 615 | 624 |
| 616 bool SocketDispatcher::Create(int type) { | 625 bool SocketDispatcher::Create(int type) { |
| 617 return Create(AF_INET, type); | 626 return Create(AF_INET, type); |
| 618 } | 627 } |
| 619 | 628 |
| 620 bool SocketDispatcher::Create(int family, int type) { | 629 bool SocketDispatcher::Create(int family, int type) { |
| 621 // Change the socket to be non-blocking. | 630 // Change the socket to be non-blocking. |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 break; | 1595 break; |
| 1587 } | 1596 } |
| 1588 } | 1597 } |
| 1589 | 1598 |
| 1590 // Done | 1599 // Done |
| 1591 return true; | 1600 return true; |
| 1592 } | 1601 } |
| 1593 #endif // WEBRTC_WIN | 1602 #endif // WEBRTC_WIN |
| 1594 | 1603 |
| 1595 } // namespace rtc | 1604 } // namespace rtc |
| OLD | NEW |