Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Windows: Could not get IPs correctly and Could not send data via sockets. #277

Closed
MegumiKasuga opened this issue May 18, 2024 · 2 comments

Comments

@MegumiKasuga
Copy link

I compiled my jar with ./build.sh host-jar and
the lib with . .\build.ps1; Build-Library -BuildType "Release" -Arch "x64" -LangBinding "java"
using cmake3, gcc 11.4.0 and OpenJDK 17.0.8 (ms build)

To fix compile errors,
I have replaced Visual Studio 16 2019 with Visual Studio 17 2022 in build.ps1 and build.sh.
replaced s_addr with S_addr in src/bindings/java/JavaSockets.cxx (line 393 and line 431)
add return 0; for

  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1get (line 594)
  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1get_1all (line 614)
  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1compute_16plane (line 626)
  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1compute_1rfc4193 (line 636)

(They are all empty method, but the compiler said that they must have something to return, so I make them all return 0)
add include_directories(${ZTO_SRC_DIR}/ext/), and changed the JNI path to my own path (in CMakeFiles.txt)

Then, I moved my lib and jar into my IDE workspace, and write an example program just like example.java

2

The program now has some Unexpected bugs:

  • Could not get IPs correctly (Included IPv4 and IPv6), The native method returns (empty) so that it(getAddressMethod) returns me with 127.0.0.1.
  • Could not send and recive datas through sockets. The program got stuck in connecting phase.

But it acts normal in:

  • joining networks.
  • get MAC address.
  • get NodeID.

I have test my program using libzt.dll of 1.8.10 and 1.8.4, and they both have the problems mentioned above.

@MegumiKasuga
Copy link
Author

Get Source Here

@MegumiKasuga
Copy link
Author

See solutions here: #267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant