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

Side by Side Diff: runtime/bin/socket_win.cc

Issue 907883002: Remove SetNonBlocking/SetBlocking methods from Socket and add missing close-on-exec (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« runtime/bin/socket_macos.cc ('K') | « runtime/bin/socket_macos.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return true; 543 return true;
544 } 544 }
545 545
546 546
547 void Socket::Close(intptr_t fd) { 547 void Socket::Close(intptr_t fd) {
548 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); 548 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd);
549 client_socket->Close(); 549 client_socket->Close();
550 } 550 }
551 551
552 552
553 static bool SetBlockingHelper(intptr_t fd, bool blocking) {
554 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
555 u_long iMode = blocking ? 0 : 1;
556 int status = ioctlsocket(handle->socket(), FIONBIO, &iMode);
557 if (status != NO_ERROR) {
558 return false;
559 }
560 return true;
561 }
562
563
564 bool Socket::SetNonBlocking(intptr_t fd) {
565 return SetBlockingHelper(fd, false);
566 }
567
568
569 bool Socket::SetBlocking(intptr_t fd) {
570 return SetBlockingHelper(fd, true);
571 }
572
573
574 bool Socket::GetNoDelay(intptr_t fd, bool* enabled) { 553 bool Socket::GetNoDelay(intptr_t fd, bool* enabled) {
575 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd); 554 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
576 int on; 555 int on;
577 socklen_t len = sizeof(on); 556 socklen_t len = sizeof(on);
578 int err = getsockopt(handle->socket(), 557 int err = getsockopt(handle->socket(),
579 IPPROTO_TCP, 558 IPPROTO_TCP,
580 TCP_NODELAY, 559 TCP_NODELAY,
581 reinterpret_cast<char *>(&on), 560 reinterpret_cast<char *>(&on),
582 &len); 561 &len);
583 if (err == 0) { 562 if (err == 0) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 proto, 697 proto,
719 MCAST_LEAVE_GROUP, 698 MCAST_LEAVE_GROUP,
720 reinterpret_cast<char *>(&mreq), 699 reinterpret_cast<char *>(&mreq),
721 sizeof(mreq)) == 0; 700 sizeof(mreq)) == 0;
722 } 701 }
723 702
724 } // namespace bin 703 } // namespace bin
725 } // namespace dart 704 } // namespace dart
726 705
727 #endif // defined(TARGET_OS_WINDOWS) 706 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« runtime/bin/socket_macos.cc ('K') | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698