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

Side by Side Diff: src/platform-macos.cc

Issue 50036: Add support for setting the SO_REUSEADDR option for sockets (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | « src/platform-linux.cc ('k') | src/platform-win32.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // Client initialization. 586 // Client initialization.
587 bool Connect(const char* host, const char* port); 587 bool Connect(const char* host, const char* port);
588 588
589 // Shutdown socket for both read and write. 589 // Shutdown socket for both read and write.
590 bool Shutdown(); 590 bool Shutdown();
591 591
592 // Data Transimission 592 // Data Transimission
593 int Send(const char* data, int len) const; 593 int Send(const char* data, int len) const;
594 int Receive(char* data, int len) const; 594 int Receive(char* data, int len) const;
595 595
596 bool SetReuseAddress(bool reuse_address);
597
596 bool IsValid() const { return socket_ != -1; } 598 bool IsValid() const { return socket_ != -1; }
597 599
598 private: 600 private:
599 int socket_; 601 int socket_;
600 }; 602 };
601 603
602 604
603 bool MacOSSocket::Bind(const int port) { 605 bool MacOSSocket::Bind(const int port) {
604 if (!IsValid()) { 606 if (!IsValid()) {
605 return false; 607 return false;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 return status; 690 return status;
689 } 691 }
690 692
691 693
692 int MacOSSocket::Receive(char* data, int len) const { 694 int MacOSSocket::Receive(char* data, int len) const {
693 int status = recv(socket_, data, len, 0); 695 int status = recv(socket_, data, len, 0);
694 return status; 696 return status;
695 } 697 }
696 698
697 699
700 bool MacOSSocket::SetReuseAddress(bool reuse_address) {
701 int on = reuse_address ? 1 : 0;
702 int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
703 return status == 0;
704 }
705
706
698 bool Socket::Setup() { 707 bool Socket::Setup() {
699 // Nothing to do on MacOS. 708 // Nothing to do on MacOS.
700 return true; 709 return true;
701 } 710 }
702 711
703 712
704 int Socket::LastError() { 713 int Socket::LastError() {
705 return errno; 714 return errno;
706 } 715 }
707 716
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 833 }
825 834
826 // This sampler is no longer the active sampler. 835 // This sampler is no longer the active sampler.
827 active_sampler_ = NULL; 836 active_sampler_ = NULL;
828 active_ = false; 837 active_ = false;
829 } 838 }
830 839
831 #endif // ENABLE_LOGGING_AND_PROFILING 840 #endif // ENABLE_LOGGING_AND_PROFILING
832 841
833 } } // namespace v8::internal 842 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698