OLD | NEW |
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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // Client initialization. | 661 // Client initialization. |
662 bool Connect(const char* host, const char* port); | 662 bool Connect(const char* host, const char* port); |
663 | 663 |
664 // Shutdown socket for both read and write. | 664 // Shutdown socket for both read and write. |
665 bool Shutdown(); | 665 bool Shutdown(); |
666 | 666 |
667 // Data Transimission | 667 // Data Transimission |
668 int Send(const char* data, int len) const; | 668 int Send(const char* data, int len) const; |
669 int Receive(char* data, int len) const; | 669 int Receive(char* data, int len) const; |
670 | 670 |
| 671 bool SetReuseAddress(bool reuse_address); |
| 672 |
671 bool IsValid() const { return socket_ != -1; } | 673 bool IsValid() const { return socket_ != -1; } |
672 | 674 |
673 private: | 675 private: |
674 int socket_; | 676 int socket_; |
675 }; | 677 }; |
676 | 678 |
677 | 679 |
678 bool LinuxSocket::Bind(const int port) { | 680 bool LinuxSocket::Bind(const int port) { |
679 if (!IsValid()) { | 681 if (!IsValid()) { |
680 return false; | 682 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 return status; | 759 return status; |
758 } | 760 } |
759 | 761 |
760 | 762 |
761 int LinuxSocket::Receive(char* data, int len) const { | 763 int LinuxSocket::Receive(char* data, int len) const { |
762 int status = recv(socket_, data, len, 0); | 764 int status = recv(socket_, data, len, 0); |
763 return status; | 765 return status; |
764 } | 766 } |
765 | 767 |
766 | 768 |
| 769 bool LinuxSocket::SetReuseAddress(bool reuse_address) { |
| 770 int on = reuse_address ? 1 : 0; |
| 771 int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
| 772 return status == 0; |
| 773 } |
| 774 |
| 775 |
767 bool Socket::Setup() { | 776 bool Socket::Setup() { |
768 // Nothing to do on Linux. | 777 // Nothing to do on Linux. |
769 return true; | 778 return true; |
770 } | 779 } |
771 | 780 |
772 | 781 |
773 int Socket::LastError() { | 782 int Socket::LastError() { |
774 return errno; | 783 return errno; |
775 } | 784 } |
776 | 785 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } | 902 } |
894 | 903 |
895 // This sampler is no longer the active sampler. | 904 // This sampler is no longer the active sampler. |
896 active_sampler_ = NULL; | 905 active_sampler_ = NULL; |
897 active_ = false; | 906 active_ = false; |
898 } | 907 } |
899 | 908 |
900 #endif // ENABLE_LOGGING_AND_PROFILING | 909 #endif // ENABLE_LOGGING_AND_PROFILING |
901 | 910 |
902 } } // namespace v8::internal | 911 } } // namespace v8::internal |
OLD | NEW |