| 235 | } |
| 236 | |
| 237 | void MessageServer::Send(LemonMessage* msg, int fd){ |
| 238 | if(fd < 0) { |
| 239 | printf("Invalid fd: %i\n", fd); |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | msg->magic = LEMON_MESSAGE_MAGIC; |
| 244 | |
| 245 | ssize_t sent = send(fd, msg, msg->length + sizeof(LemonMessage), MSG_DONTWAIT); |
| 246 | |
| 247 | if(sent <= 0){ |
| 248 | perror("Warning: Send: "); |
| 249 | } else if(sent < msg->length + static_cast<short>(sizeof(LemonMessage))){ |
| 250 | printf("Warning: Tried to send %lu bytes, but only sent %ld bytes", msg->length + sizeof(LemonMessage), sent); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | void MessageServer::Send(const Message& msg, int fd){ |
| 255 | if(fd < 0) { |