OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 #if defined(FLETCH_TARGET_OS_POSIX) && defined(FLETCH_ENABLE_LIVE_CODING) | 5 #if defined(DARTINO_TARGET_OS_POSIX) && defined(DARTINO_ENABLE_LIVE_CODING) |
6 | 6 |
7 #include "src/shared/native_socket.h" | 7 #include "src/shared/native_socket.h" |
8 | 8 |
9 #include <arpa/inet.h> | 9 #include <arpa/inet.h> |
10 #include <errno.h> | 10 #include <errno.h> |
11 #include <fcntl.h> | 11 #include <fcntl.h> |
12 #include <netdb.h> | 12 #include <netdb.h> |
13 #include <netinet/tcp.h> | 13 #include <netinet/tcp.h> |
14 #include <stdlib.h> | 14 #include <stdlib.h> |
15 #include <sys/socket.h> | 15 #include <sys/socket.h> |
16 #include <unistd.h> | 16 #include <unistd.h> |
17 | 17 |
18 #include "src/shared/assert.h" | 18 #include "src/shared/assert.h" |
19 #include "src/shared/utils.h" | 19 #include "src/shared/utils.h" |
20 | 20 |
21 namespace fletch { | 21 namespace dartino { |
22 | 22 |
23 struct Socket::SocketData { | 23 struct Socket::SocketData { |
24 SocketData() : fd(-1) {} | 24 SocketData() : fd(-1) {} |
25 explicit SocketData(int fd) : fd(fd) {} | 25 explicit SocketData(int fd) : fd(fd) {} |
26 | 26 |
27 int fd; | 27 int fd; |
28 }; | 28 }; |
29 | 29 |
30 Socket::Socket() : data_(new SocketData()) { | 30 Socket::Socket() : data_(new SocketData()) { |
31 data_->fd = socket(AF_INET, SOCK_STREAM, 0); | 31 data_->fd = socket(AF_INET, SOCK_STREAM, 0); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 int Socket::FileDescriptor() { return data_->fd; } | 155 int Socket::FileDescriptor() { return data_->fd; } |
156 | 156 |
157 void Socket::SetTCPNoDelay(bool value) { | 157 void Socket::SetTCPNoDelay(bool value) { |
158 int option = value ? 1 : 0; | 158 int option = value ? 1 : 0; |
159 int status = | 159 int status = |
160 setsockopt(data_->fd, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)); | 160 setsockopt(data_->fd, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)); |
161 if (status == -1) perror("Failed setting TCP_NODELAY socket options."); | 161 if (status == -1) perror("Failed setting TCP_NODELAY socket options."); |
162 } | 162 } |
163 | 163 |
164 } // namespace fletch | 164 } // namespace dartino |
165 | 165 |
166 #endif // def'd(FLETCH_TARGET_OS_POSIX) && def'd(FLETCH_ENABLE_LIVE_CODING) | 166 #endif // def'd(DARTINO_TARGET_OS_POSIX) && def'd(DARTINO_ENABLE_LIVE_CODING) |
OLD | NEW |