kb_socket.h File Reference

Include dependency graph for kb_socket.h:

This graph shows which files directly or indirectly include this file:

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 Documentation

#define MAXPENDING   5

Definition at line 17 of file kb_socket.h.

Referenced by ksock_server_open().


Typedef Documentation

typedef struct ksock_s ksock_t


Function Documentation

int ksock_connect ( char *  servIP,
unsigned short  servPort 
)

Try to connect to the given server

Parameters:
clntSocket The connection id
cmdBuffer The receive buffer allocated by the caller
bufSize The size of the receive buffer
Returns:
  • the socket descriptor

Definition at line 370 of file kb_socket.c.

References DieWithError(), and sock.

Referenced by main().

Here is the call graph for this function:

int ksock_exec_command ( char *  cmd  ) 

Execute a network command

Parameters:
cmd the command line
Returns:
  • the return value of the command if succesful
  • KB_ERROR_INVAL if the command is invalid
  • KB_ERROR_TOOMANYARGS if number of args is invalid
  • KB_ERROR_UNKCMD if the command is unknown

Definition at line 285 of file kb_socket.c.

References KB_ERROR, KB_ERROR_NOINIT, and kb_parse_command().

Referenced by main().

Here is the call graph for this function:

int ksock_exec_command_pending ( int  clntSock,
char *  cmd 
)

Send a network command through the given socket 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.

Parameters:
socket the receiving socket
cmd the command line
Execute a network command that require an answer

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.

Parameters:
cmd the command line
clntSock the connection id
Returns:
  • the return value of the command if succesful
  • KB_ERROR_INVAL if the command is invalid
  • KB_ERROR_TOOMANYARGS if number of args is invalid
  • KB_ERROR_UNKCMD if the command is unknown

Definition at line 260 of file kb_socket.c.

References KB_ALLOC, KB_ERROR, KB_ERROR_NOINIT, and kb_parse_command().

Referenced by main().

Here is the call graph for this function:

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().

Here is the call graph for this function:

int ksock_send_command ( int  socket,
char *  cmd,
  ... 
)

Send a network command through the given socket

Parameters:
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().

Here is the call graph for this function:

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().

Here is the call graph for this function:


Generated on Wed Dec 15 11:49:28 2010 for KoreBot Library by  doxygen 1.5.5