C3E: Complex Compute Core Engine v1.0
An engine for handling complex computational tasks
Loading...
Searching...
No Matches
net.h File Reference

Network communication utilities for the C3E library. More...

#include <c3e/commons.h>
#include <arpa/inet.h>
Include dependency graph for net.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  c3e_socket
 Represents a network socket for communication. More...
 

Functions

void c3e_socket_init (c3e_socket *socket, const char *hostname, int port)
 Initializes a socket with the specified hostname and port.
 
void c3e_socket_close (c3e_socket *socket)
 Closes the network socket.
 
bool c3e_socket_send_data (c3e_socket *socket, const void *data, size_t size)
 Sends data through the socket.
 
bool c3e_socket_receive_data (c3e_socket *socket, void *buffer, size_t size)
 Receives data from the socket.
 
void c3e_socket_send_tensor (c3e_socket *socket, c3e_tensor *tensor)
 Sends a tensor object through the socket.
 
void c3e_socket_send_matrix (c3e_socket *socket, c3e_matrix *matrix)
 Sends a matrix object 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_number (c3e_socket *socket, c3e_number number)
 Sends a numerical value over a socket connection.
 
c3e_tensorc3e_socket_tensor_read (c3e_socket *socket)
 Receives and deserializes a tensor object from the socket.
 
c3e_matrixc3e_socket_matrix_read (c3e_socket *socket)
 Receives and deserializes a matrix object from the socket.
 
c3e_vectorc3e_socket_vector_read (c3e_socket *socket)
 Receives and deserializes a vector object from the socket.
 
c3e_number c3e_socket_number_read (c3e_socket *socket)
 Receives a numerical value from a socket connection.
 

Detailed Description

Author
Nathanne Isip

This file provides functionalities for network communication within the C3E library. It includes definitions and functions for socket management, as well as sending and receiving data structures such as vectors, matrices, and tensors over a network.

Function Documentation

◆ c3e_socket_close()

void c3e_socket_close ( c3e_socket socket)

This function releases the resources associated with the socket and closes the connection.

Parameters
socketA pointer to the c3e_socket structure to be closed.

◆ c3e_socket_init()

void c3e_socket_init ( c3e_socket socket,
const char *  hostname,
int  port 
)

This function sets up a network socket for communication with a server. It configures the socket's address and port, and prepares it for use in sending and receiving data.

Parameters
socketA pointer to a c3e_socket structure to be initialized.
hostnameThe hostname or IP address of the server.
portThe port number on which the server is listening.

◆ c3e_socket_matrix_read()

c3e_matrix * c3e_socket_matrix_read ( c3e_socket socket)

This function reads and reconstructs a c3e_matrix object from the data received through the network.

Parameters
socketA pointer to the c3e_socket structure used for receiving the matrix.
Returns
A pointer to the deserialized c3e_matrix object. NULL if the operation fails.

◆ c3e_socket_number_read()

c3e_number c3e_socket_number_read ( c3e_socket socket)

This function reads a c3e_number type value from the specified socket.

Parameters
socketA pointer to a c3e_socket structure representing the socket connection from which the data will be received.
Returns
The numerical value of type c3e_number that was received from the socket.

◆ c3e_socket_receive_data()

bool c3e_socket_receive_data ( c3e_socket socket,
void *  buffer,
size_t  size 
)

This function reads data from the network through the specified socket and stores it in the provided buffer.

Parameters
socketA pointer to the c3e_socket structure used for receiving data.
bufferA pointer to the buffer where received data will be stored.
sizeThe size of the buffer.
Returns
true if the data was successfully received, false otherwise.

◆ c3e_socket_send_data()

bool c3e_socket_send_data ( c3e_socket socket,
const void *  data,
size_t  size 
)

This function transmits data over the network through the specified socket.

Parameters
socketA pointer to the c3e_socket structure used for sending data.
dataA pointer to the data to be sent.
sizeThe size of the data to be sent.
Returns
true if the data was successfully sent, false otherwise.

◆ c3e_socket_send_matrix()

void c3e_socket_send_matrix ( c3e_socket socket,
c3e_matrix matrix 
)

This function serializes and transmits a c3e_matrix object over the network.

Parameters
socketA pointer to the c3e_socket structure used for sending the matrix.
matrixA pointer to the c3e_matrix object to be sent.

◆ c3e_socket_send_number()

void c3e_socket_send_number ( c3e_socket socket,
c3e_number  number 
)

This function sends a c3e_number type value through the specified socket. It uses the c3e_socket_send_data function to transmit the binary representation of the number.

Parameters
socketA pointer to a c3e_socket structure representing the socket connection through which the data will be sent.
numberThe numerical value of type c3e_number to be sent. This value is sent as a binary stream, which means the receiving end should be aware of the data format to correctly interpret it.

◆ c3e_socket_send_tensor()

void c3e_socket_send_tensor ( c3e_socket socket,
c3e_tensor tensor 
)

This function serializes and transmits a c3e_tensor object over the network.

Parameters
socketA pointer to the c3e_socket structure used for sending the tensor.
tensorA pointer to the c3e_tensor object to be sent.

◆ c3e_socket_send_vector()

void c3e_socket_send_vector ( c3e_socket socket,
c3e_vector vector 
)

This function serializes and transmits a c3e_vector object over the network.

Parameters
socketA pointer to the c3e_socket structure used for sending the vector.
vectorA pointer to the c3e_vector object to be sent.

◆ c3e_socket_tensor_read()

c3e_tensor * c3e_socket_tensor_read ( c3e_socket socket)

This function reads and reconstructs a c3e_tensor object from the data received through the network.

Parameters
socketA pointer to the c3e_socket structure used for receiving the tensor.
Returns
A pointer to the deserialized c3e_tensor object. NULL if the operation fails.

◆ c3e_socket_vector_read()

c3e_vector * c3e_socket_vector_read ( c3e_socket socket)

This function reads and reconstructs a c3e_vector object from the data received through the network.

Parameters
socketA pointer to the c3e_socket structure used for receiving the vector.
Returns
A pointer to the deserialized c3e_vector object. NULL if the operation fails.