OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "src/tools/driver/connection.h" | 5 #include "src/tools/driver/connection.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include "src/shared/native_socket.h" | 10 #include "src/shared/native_socket.h" |
11 #include "src/shared/utils.h" | 11 #include "src/shared/utils.h" |
12 | 12 |
13 namespace fletch { | 13 namespace dartino { |
14 | 14 |
15 DriverConnection::DriverConnection(Socket* socket) : socket_(socket) {} | 15 DriverConnection::DriverConnection(Socket* socket) : socket_(socket) {} |
16 | 16 |
17 DriverConnection::~DriverConnection() { delete socket_; } | 17 DriverConnection::~DriverConnection() { delete socket_; } |
18 | 18 |
19 DriverConnection::Command DriverConnection::Receive() { | 19 DriverConnection::Command DriverConnection::Receive() { |
20 incoming_.ClearBuffer(); | 20 incoming_.ClearBuffer(); |
21 uint8 header[kHeaderSize]; | 21 uint8 header[kHeaderSize]; |
22 size_t offset = 0; | 22 size_t offset = 0; |
23 int fd = socket_->FileDescriptor(); | 23 int fd = socket_->FileDescriptor(); |
(...skipping 18 matching lines...) Expand all Loading... |
42 } | 42 } |
43 | 43 |
44 void DriverConnection::Send(Command command, const WriteBuffer& buffer) { | 44 void DriverConnection::Send(Command command, const WriteBuffer& buffer) { |
45 uint8 header[5]; | 45 uint8 header[5]; |
46 Utils::WriteInt32(header, buffer.offset()); | 46 Utils::WriteInt32(header, buffer.offset()); |
47 header[4] = command; | 47 header[4] = command; |
48 socket_->Write(header, 5); | 48 socket_->Write(header, 5); |
49 buffer.WriteTo(socket_); | 49 buffer.WriteTo(socket_); |
50 } | 50 } |
51 | 51 |
52 } // namespace fletch | 52 } // namespace dartino |
OLD | NEW |