3D-ICE 3.0.0
|
Go to the source code of this file.
Data Structures | |
struct | Socket_t |
Structure used to set up and use network connections. More... | |
Typedefs | |
typedef struct Socket_t | Socket_t |
Functions | |
void | socket_init (Socket_t *socket) |
Error_t | open_client_socket (Socket_t *csocket) |
Error_t | open_server_socket (Socket_t *ssocket, PortNumber_t port_number) |
Error_t | connect_client_to_server (Socket_t *csocket, String_t host_name, PortNumber_t port_number) |
Error_t | wait_for_client (Socket_t *ssocket, Socket_t *client) |
Error_t | send_message_to_socket (Socket_t *socket, NetworkMessage_t *message) |
Error_t | receive_message_from_socket (Socket_t *socket, NetworkMessage_t *message) |
Error_t | socket_close (Socket_t *socket) |
Definition of the type Socket_t
Definition at line 87 of file network_socket.h.
Error_t connect_client_to_server | ( | Socket_t * | csocket, |
String_t | host_name, | ||
PortNumber_t | port_number | ||
) |
Connects the client to a server
Prepares the address of the server and establish the connection. The server side must be waiting for a connection. On error, the socket is closed.
csocket | the address of the ClientSocket to initialize |
host_name | the ip address of the server (as dotted string) |
port_number | the port number of the server |
TDICE_SUCCESS
if the connection succeeded TDICE_FAILURE
if the connections fails. A message will be printed on standard error Definition at line 124 of file network_socket.c.
Open a socket for the client side
csocket | the address of the Socket to open |
TDICE_SUCCESS
if the opening succeeded TDICE_FAILURE
if the opening fails. A message will be printed on standard error Definition at line 65 of file network_socket.c.
Error_t open_server_socket | ( | Socket_t * | ssocket, |
PortNumber_t | port_number | ||
) |
Open a socket for the server side
The function creates the socket. Then it binds the socket to the port_numebr over any kind of address. It finally enables the listening.
ssocket | the address of the Socket to open |
port_number | the port number of the server |
TDICE_SUCCESS
if the opening succeeded TDICE_FAILURE
if the opening fails. A message will be printed on standard error Definition at line 81 of file network_socket.c.
Error_t receive_message_from_socket | ( | Socket_t * | socket, |
NetworkMessage_t * | message | ||
) |
Receive a text message from a socket
socket | the socket where the message will be received |
message | the address of message to receive |
TDICE_SUCCESS
if the operation succeeded TDICE_FAILURE
if the operation fails. A message will be printed on standard error Definition at line 249 of file network_socket.c.
Error_t send_message_to_socket | ( | Socket_t * | socket, |
NetworkMessage_t * | message | ||
) |
Sends a message to a socket
socket | the socket where the message will be sent |
message | the address of message to send |
TDICE_SUCCESS
if the operation succeeded TDICE_FAILURE
if the operation fails. A message will be printed on standard error Definition at line 197 of file network_socket.c.
Closes a socket
socket | the address of the Socket to close |
TDICE_SUCCESS
if the closure succeeded TDICE_FAILURE
if the closure fails. A message will be printed on standard error Definition at line 318 of file network_socket.c.
void socket_init | ( | Socket_t * | socket | ) |
Inits the fields of the socket structure with default values
socket | the address of the structure to initalize |
Definition at line 52 of file network_socket.c.
Waits unitl a client sends a connect to the server
ssocket | the address of the ServerSocket that will wait |
client | the address of the ClientSocket that will connect_to_server |
TDICE_SUCCESS
if the connection with the client succeeded TDICE_FAILURE
if the connection fails. A message will be printed on standard error Definition at line 162 of file network_socket.c.