Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
teotcp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "ev_mgr.h"

Macros

#define TTCP_VERSION   "0.0.1"
 
#define SERVER_PORT   9050
 
#define BUF_LEN   1024
 

Functions

void tcp_server_receive_cb (struct ev_loop *loop, ev_io *w, int revents)
 TCP server receive data from client callback. More...
 
void tcp_server_accept_cb (struct ev_loop *loop, ev_ksnet_io *w, int revents, int fd)
 TCP server accept callback. More...
 
void event_cb (ksnetEvMgrClass *ke, ksnetEvMgrEvents event, void *data, size_t data_len, void *user_data)
 Teonet Events callback. More...
 
int main (int argc, char **argv)
 Main Teotcp application function. More...
 

Detailed Description

Macro Definition Documentation

#define BUF_LEN   1024
Examples:
teotcp.c.

Referenced by tcp_server_receive_cb(), and test_01().

#define SERVER_PORT   9050
Examples:
teotcp.c.

Referenced by event_cb().

#define TTCP_VERSION   "0.0.1"
Examples:
teotcp.c.

Referenced by main().

Function Documentation

void event_cb ( ksnetEvMgrClass ke,
ksnetEvMgrEvents  event,
void *  data,
size_t  data_len,
void *  user_data 
)

Teonet Events callback.

Parameters
ke
event
data
data_len
user_data
Examples:
teotcp.c.

References teonet_cfg::app_argv, EV_K_STARTED, free(), ksnet_formatMessage(), ksnetEvMgrStop(), ksnTcpServerCreate(), ksnetEvMgrClass::kt, SERVER_PORT, tcp_server_accept_cb(), and ksnetEvMgrClass::teo_cfg.

Referenced by main().

int main ( int  argc,
char **  argv 
)

Main Teotcp application function.

Parameters
argcNumber of parameters
argvParameters array
Returns
EXIT_SUCCESS
Examples:
teotcp.c.

References ksnetEvMgrAppParam::app_argc, ksnetEvMgrAppParam::app_argv, ksnetEvMgrAppParam::app_descr, APP_PARAM, event_cb(), ke, ksnetEvMgrInitPort(), ksnetEvMgrRun(), READ_CONFIGURATION, READ_OPTIONS, TTCP_VERSION, and VERSION.

void tcp_server_accept_cb ( struct ev_loop *  loop,
ev_ksnet_io w,
int  revents,
int  fd 
)

TCP server accept callback.

Parameters
loop
w
revents
fd
Examples:
teotcp.c.

References ev_ksnet_io::io, ksnTcpCb(), and tcp_server_receive_cb().

Referenced by event_cb().

void tcp_server_receive_cb ( struct ev_loop *  loop,
ev_io *  w,
int  revents 
)

TCP server receive data from client callback.

Parameters
loop
w
revents
Examples:
teotcp.c.

References BUF_LEN, fd, free(), ksnTcpCbStop(), ksnTcpGetServer(), ksnTcpServerStopAll(), and ksnTcpServerStopAllClients().

Referenced by tcp_server_accept_cb().