Go to the source code of this file.
Data Structures | |
struct | ksock_s |
Defines | |
#define | MAXPENDING 5 |
Typedefs | |
typedef struct ksock_s | ksock_t |
Functions | |
int | ksock_server_open (ksock_t *server, unsigned short port) |
int | ksock_next_connection (ksock_t *server) |
int | ksock_exec_command (char *cmd) |
int | ksock_exec_command_pending (int clntSock, char *cmd) |
int | ksock_send_command (int socket, char *cmd,...) |
int | ksock_connect (char *servIP, unsigned short servPort) |
#define MAXPENDING 5 |
Definition at line 17 of file kb_socket.h.
Referenced by ksock_server_open().
KoreBot library socket interface provides an high level server socket interface.
Korebot socket struct
int ksock_connect | ( | char * | servIP, | |
unsigned short | servPort | |||
) |
Try to connect to the given server
servIP | server IP | |
servPort | server port |
Definition at line 364 of file kb_socket.c.
References DieWithError(), and sock.
Referenced by main().
int ksock_exec_command | ( | char * | cmd | ) |
Execute a network command
cmd | the command line |
Definition at line 280 of file kb_socket.c.
References KB_ERROR, KB_ERROR_NOINIT, and kb_parse_command().
Referenced by main().
int ksock_exec_command_pending | ( | int | clntSock, | |
char * | cmd | |||
) |
Execute a network command that require an answer and wait for an acknowledge from the server. If the acknowledge is not received before the given timeout, the function returns with an error code.
The application should send the corresponding answer using ksock_send_answer.
Such network commands must use the following syntax: The fisrt word is the command name. The second word is the request id (unsigned long integer). The following words are the command parameters.
clntSock | the connection id | |
cmd | the command line |
Definition at line 255 of file kb_socket.c.
References KB_ALLOC, KB_ERROR, KB_ERROR_NOINIT, and kb_parse_command().
Referenced by main().
int ksock_next_connection | ( | ksock_t * | server | ) |
Get the next connection to the given server
Definition at line 82 of file kb_socket.c.
References DieWithError(), KB_WARN_CONNECT, kb_warning(), and ksock_s::serv_socket.
Referenced by main().
int ksock_send_command | ( | int | socket, | |
char * | cmd, | |||
... | ||||
) |
Send a network command through the given socket
socket | the receiving socket | |
cmd | the command line |
Definition at line 186 of file kb_socket.c.
References DieWithError(), ksock_buf_len, ksock_buf_snd, and ksock_command_terminator.
Referenced by handle_joyaxis(), and handle_joybutton().
int ksock_server_open | ( | ksock_t * | server, | |
unsigned short | port | |||
) |
Open a server socket
Definition at line 54 of file kb_socket.c.
References DieWithError(), MAXPENDING, ksock_s::serv_addr, and ksock_s::serv_socket.
Referenced by main().