Minor updates to Java ExampleApp and added select() to JNI layer

This commit is contained in:
Joseph Henry
2018-09-06 11:08:06 -07:00
parent 6e06cb36ff
commit 84fcfd3baf
5 changed files with 109 additions and 24 deletions

View File

@@ -95,8 +95,8 @@ void load_library_symbols(char *library_path)
{
void *libHandle = dlopen(library_path, RTLD_LAZY);
if (libHandle == NULL) {
DEBUG_ERROR("unable to load dynamic lib");
exit(0);
DEBUG_ERROR("unable to load dynamic libs: %s", dlerror());
exit(-1);
}
// Load symbols from library (call these directly)
@@ -150,7 +150,6 @@ void load_library_symbols(char *library_path)
_zts_add_dns_nameserver = (int(*)(struct sockaddr *addr))dlsym(libHandle, "zts_add_dns_nameserver");
}
int main(int argc, char **argv)
{
if (argc != 4) {
@@ -158,6 +157,15 @@ int main(int argc, char **argv)
printf("server [config_file_path] [nwid] [bind_port]\n");
exit(0);
}
#ifdef __linux__
char *library_path = (char*)"./libzt.so";
#endif
#ifdef __APPLE__
char *library_path = (char*)"./libzt.dylib";
#endif
load_library_symbols(library_path);
std::string path = argv[1];
std::string nwidstr = argv[2];
int bind_port = atoi(argv[3]);
@@ -170,10 +178,7 @@ int main(int argc, char **argv)
in4.sin_addr.s_addr = INADDR_ANY;
in4.sin_family = AF_INET;
// --- BEGIN EXAMPLE CODE
char *library_path = (char*)"bin/lib/libzt.dylib";
load_library_symbols(library_path);
//
printf("Waiting for libzt to come online...\n");
uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);