C3E: Complex Compute Core Engine v1.0
An engine for handling complex computational tasks
Loading...
Searching...
No Matches
net.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Nathanne Isip
3 *
4 * Redistribution and use in source and binary forms,
5 * with or without modification, are permitted provided
6 * that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the
9 * above copyright notice, this list of conditions
10 * and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the
13 * above copyright notice, this list of conditions
14 * and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 */
17
27#ifndef C3E_NET_H
28#define C3E_NET_H
29
30#include <c3e/commons.h>
31
32#include <arpa/inet.h>
33
44typedef struct {
45 char* hostname;
46 int port;
47 int sockfd;
48 struct sockaddr_in server_addr;
50
61void c3e_socket_init(c3e_socket* socket, const char* hostname, int port);
62
71
82bool c3e_socket_send_data(c3e_socket* socket, const void* data, size_t size);
83
94bool c3e_socket_receive_data(c3e_socket* socket, void* buffer, size_t size);
95
105
115
125
126
140
150
160
170
181
182#endif /* C3E_NET_H */
Common data structures and type definitions for the C3E library.
double c3e_number
A type representing a numerical value in C3E. Defaults to double precision.
Definition commons.h:50
void c3e_socket_close(c3e_socket *socket)
Closes the network socket.
c3e_vector * c3e_socket_vector_read(c3e_socket *socket)
Receives and deserializes a vector object from the socket.
c3e_tensor * c3e_socket_tensor_read(c3e_socket *socket)
Receives and deserializes a tensor object from the socket.
bool c3e_socket_send_data(c3e_socket *socket, const void *data, size_t size)
Sends data through the socket.
void c3e_socket_send_vector(c3e_socket *socket, c3e_vector *vector)
Sends a vector object through the socket.
void c3e_socket_send_tensor(c3e_socket *socket, c3e_tensor *tensor)
Sends a tensor object through the socket.
void c3e_socket_send_number(c3e_socket *socket, c3e_number number)
Sends a numerical value over a socket connection.
void c3e_socket_init(c3e_socket *socket, const char *hostname, int port)
Initializes a socket with the specified hostname and port.
c3e_number c3e_socket_number_read(c3e_socket *socket)
Receives a numerical value from a socket connection.
void c3e_socket_send_matrix(c3e_socket *socket, c3e_matrix *matrix)
Sends a matrix object through the socket.
c3e_matrix * c3e_socket_matrix_read(c3e_socket *socket)
Receives and deserializes a matrix object from the socket.
bool c3e_socket_receive_data(c3e_socket *socket, void *buffer, size_t size)
Receives data from the socket.
Represents a mathematical matrix.
Definition commons.h:74
Represents a network socket for communication.
Definition net.h:44
char * hostname
The hostname or IP address of the server.
Definition net.h:45
int port
The port number on which the server is listening.
Definition net.h:46
int sockfd
The file descriptor for the socket.
Definition net.h:47
Represents a tensor, a multi-dimensional array of numerical values.
Definition commons.h:111
Represents a mathematical vector.
Definition commons.h:62