]> git.meshlink.io Git - meshlink/blob - meshlink-sample/meshlinkapp.c
Be carefull there is a race condition. You need myself to be allocated or going to...
[meshlink] / meshlink-sample / meshlinkapp.c
1 #include <libmeshlink.h>
2
3 int main(int argc , char **argv){
4
5 char *confbase = "/tmp/meshlink/";
6 char *name = "test";
7
8 tincremotehost* remotenode = malloc(sizeof(tincremotehost));
9 char *remotename = "nameofremotenode";
10
11 //TODO: change this, calling a function that returns tincremotehost
12 remotenode->name = remotename;
13 remotenode->publickey = NULL;
14
15 tinc_setup(confbase, name);
16 tinc_start(confbase);
17 sleep(2); //there is a race condition here, tinc_start detaches to a thread the needs time to setup stuff
18 while(1) {
19
20 //sample data to send out
21 char mydata[200];
22 memset(mydata,0,200);
23 strcpy(mydata,"Hello World!");
24
25 //send out data
26 tinc_send_packet(remotenode,mydata,sizeof(mydata));
27 sleep(10); //give time to this thread to finish before we exit
28 }
29 free(remotenode);
30 return 0;
31 }
32