]> git.meshlink.io Git - meshlink/blobdiff - 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
index 7dd7f501c715f3f362b1d8c51eb33c5ec202017f..0ec564e37b6f149b17c457e0706a9bc637420ba9 100644 (file)
@@ -5,12 +5,28 @@ int main(int argc , char **argv){
 char *confbase = "/tmp/meshlink/";
 char *name = "test";
 
+tincremotehost* remotenode = malloc(sizeof(tincremotehost));
+char *remotename = "nameofremotenode";
+
+//TODO: change this, calling a function that returns tincremotehost
+remotenode->name = remotename;
+remotenode->publickey = NULL;
+
 tinc_setup(confbase, name);
 tinc_start(confbase);
+sleep(2); //there is a race condition here, tinc_start detaches to a thread the needs time to setup stuff
 while(1) {
+
+//sample data to send out
+char mydata[200];
+memset(mydata,0,200);
+strcpy(mydata,"Hello World!");
+
+//send out data
+tinc_send_packet(remotenode,mydata,sizeof(mydata));
 sleep(10); //give time to this thread to finish before we exit
-tinc_send_packet(NULL,"datafgsdfsd",10);
 }
+free(remotenode);
 return 0;
 }