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