mirror of
https://github.com/vale981/ray
synced 2025-03-13 14:46:38 -04:00

* Allow reading/writing generic message types, not just tasks. * Allow messages of length 0 to be read/written, and handle closed sockets. * Address comments. * Simplify accept_client. * Allow ports to be reused in bind_ipc_sock.
31 lines
767 B
C
31 lines
767 B
C
#ifndef IO_H
|
|
#define IO_H
|
|
|
|
#include <stdint.h>
|
|
|
|
enum common_message_type {
|
|
/** Disconnect a client. */
|
|
DISCONNECT_CLIENT,
|
|
/** Log a message from a client. */
|
|
LOG_MESSAGE,
|
|
/** Submit a task to the local scheduler. */
|
|
SUBMIT_TASK,
|
|
};
|
|
|
|
/* Helper functions for socket communication. */
|
|
|
|
int bind_ipc_sock(const char *socket_pathname);
|
|
int connect_ipc_sock(const char *socket_pathname);
|
|
|
|
int accept_client(int socket_fd);
|
|
|
|
/* Reading and writing data */
|
|
|
|
void write_message(int fd, int64_t type, int64_t length, uint8_t *bytes);
|
|
void read_message(int fd, int64_t *type, int64_t *length, uint8_t **bytes);
|
|
|
|
void write_log_message(int fd, char *message);
|
|
void write_formatted_log_message(int fd, const char *format, ...);
|
|
char *read_log_message(int fd);
|
|
|
|
#endif
|