Modification to blocking bahavior of zts_start, is now settable. Improved address family handling in JNI

This commit is contained in:
Joseph Henry
2017-10-16 16:45:46 -07:00
parent ce22940f57
commit 45260c4e69
13 changed files with 199 additions and 242 deletions

View File

@@ -33,6 +33,7 @@ public class ExampleApp {
public native int loadsymbols();
public native void startOneService();
// load libzt.dylib or libzt.so
static {
System.loadLibrary("zt");
}
@@ -45,11 +46,21 @@ public class ExampleApp {
public void run() {
System.out.println("starting libzt");
libzt.startjoin("/Users/joseph/op/zt/libzt/ztjni", "1212121212121212");
System.out.println("started.");
// start(path) will not block
// startjoin(path, nwid) will block
int fd = 0, err = 0;
if ((fd = libzt.socket(libzt.AF_INET, libzt.SOCK_STREAM, 0)) < 0) {
System.out.println("error creating socket");
return;
}
if ((err = libzt.bind(fd, "0.0.0.0", 3000)) < 0) {
System.out.println("error binding socket to virtual interface");
return;
}
}
}).start();
while(true)
{
try { Thread.sleep(3000); }