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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 // Server initialization. | 649 // Server initialization. |
650 bool Bind(const int port); | 650 bool Bind(const int port); |
651 bool Listen(int backlog) const; | 651 bool Listen(int backlog) const; |
652 Socket* Accept() const; | 652 Socket* Accept() const; |
653 | 653 |
654 // Client initialization. | 654 // Client initialization. |
655 bool Connect(const char* host, const char* port); | 655 bool Connect(const char* host, const char* port); |
656 | 656 |
657 // Data Transimission | 657 // Data Transimission |
658 int Send(const char* data, int len) const; | 658 int Send(const char* data, int len) const; |
659 bool SendAll(const char* data, int len) const; | |
660 int Receive(char* data, int len) const; | 659 int Receive(char* data, int len) const; |
661 | 660 |
662 bool IsValid() const { return socket_ != -1; } | 661 bool IsValid() const { return socket_ != -1; } |
663 | 662 |
664 private: | 663 private: |
665 int socket_; | 664 int socket_; |
666 }; | 665 }; |
667 | 666 |
668 | 667 |
669 bool FreeBSDSocket::Bind(const int port) { | 668 bool FreeBSDSocket::Bind(const int port) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 return status == 0; | 728 return status == 0; |
730 } | 729 } |
731 | 730 |
732 | 731 |
733 int FreeBSDSocket::Send(const char* data, int len) const { | 732 int FreeBSDSocket::Send(const char* data, int len) const { |
734 int status = send(socket_, data, len, 0); | 733 int status = send(socket_, data, len, 0); |
735 return status; | 734 return status; |
736 } | 735 } |
737 | 736 |
738 | 737 |
739 bool FreeBSDSocket::SendAll(const char* data, int len) const { | |
740 int sent_len = 0; | |
741 while (sent_len < len) { | |
742 int status = Send(data, len); | |
743 if (status <= 0) { | |
744 return false; | |
745 } | |
746 sent_len += status; | |
747 } | |
748 return true; | |
749 } | |
750 | |
751 | |
752 int FreeBSDSocket::Receive(char* data, int len) const { | 738 int FreeBSDSocket::Receive(char* data, int len) const { |
753 int status = recv(socket_, data, len, 0); | 739 int status = recv(socket_, data, len, 0); |
754 return status; | 740 return status; |
755 } | 741 } |
756 | 742 |
757 | 743 |
758 bool Socket::Setup() { | 744 bool Socket::Setup() { |
759 // Nothing to do on FreeBSD. | 745 // Nothing to do on FreeBSD. |
760 return true; | 746 return true; |
761 } | 747 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 } | 870 } |
885 | 871 |
886 // This sampler is no longer the active sampler. | 872 // This sampler is no longer the active sampler. |
887 active_sampler_ = NULL; | 873 active_sampler_ = NULL; |
888 active_ = false; | 874 active_ = false; |
889 } | 875 } |
890 | 876 |
891 #endif // ENABLE_LOGGING_AND_PROFILING | 877 #endif // ENABLE_LOGGING_AND_PROFILING |
892 | 878 |
893 } } // namespace v8::internal | 879 } } // namespace v8::internal |
OLD | NEW |