brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | #ifndef AOS_NETWORK_SEND_SOCKET_H_ |
| 2 | #define AOS_NETWORK_SEND_SOCKET_H_ |
| 3 | |
| 4 | #include "Socket.h" |
| 5 | |
| 6 | namespace aos { |
| 7 | |
| 8 | class SendSocket : public Socket { |
| 9 | public: |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 10 | // Connect must be called before use. |
| 11 | SendSocket() {} |
| 12 | // Calls Connect automatically. |
Brian Silverman | a9cbe30 | 2013-03-12 18:41:44 -0700 | [diff] [blame^] | 13 | SendSocket(NetworkPort port, const char *robot_ip) { |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 14 | Connect(port, robot_ip); |
| 15 | } |
Brian Silverman | a9cbe30 | 2013-03-12 18:41:44 -0700 | [diff] [blame^] | 16 | int Connect(NetworkPort port, const char *robot_ip, int type = SOCK_DGRAM); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 17 | |
| 18 | static const size_t MAX_MSG = 4096; |
Brian Silverman | a9cbe30 | 2013-03-12 18:41:44 -0700 | [diff] [blame^] | 19 | char hold_msg_[MAX_MSG]; |
| 20 | size_t hold_msg_len_; |
| 21 | int SendHoldMsg(); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | } // namespace aos |
| 25 | |
| 26 | #endif |
| 27 | |