Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
teolarge.c

Send and receive large data blocks between teonet applications

How to execute this test:

1) Start one teonet test application in terminal:

 examples/teolarge teolarge -p 9500

2) Start another test application in other terminal:

 examples/teolarge teorecv -r 9500 -a 127.0.0.1

The first application with name teolarge will send data blocks 2048 bytes length to the teorecv application.

Created on July 18, 2015, 3:06 PM

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ev_mgr.h"
#define TLARGE_VERSION VERSION
size_t data_len, void *user_data) {
switch(event) {
// Send by timer
case EV_K_TIMER:
{
char buffer[KSN_BUFFER_DB_SIZE];
const char *teorecv = "teorecv";
if(strcmp(teorecv, ksnetEvMgrGetHostName(ke))) {
strcpy(buffer, "Large Hello!");
ksnCoreSendCmdto(ke->kc, (char*)teorecv, CMD_USER, buffer,
}
}
break;
// Send when data received
{
printf("Command: %d, Data: %s (%d bytes), got from: %s\n",
rd->cmd, (char*)rd->data, (int)rd->data_len, rd->from);
}
break;
// Undefined event (an error)
default:
break;
}
}
int main(int argc, char** argv) {
printf("Teolarge " TLARGE_VERSION "\n");
// Initialize teonet event manager and Read configuration
// Set custom timer interval
// Hello message
ksnet_printf(&ke->teo_cfg, MESSAGE, "Started...\n\n");
// Start teonet
return (EXIT_SUCCESS);
}