• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Socket binding through JNI

Resolved: Socket binding through JNI

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I try to open a socket connection on a Linux machine through JNI. If I combine Java_Socket_socket and Java_Socket_bind in same C function, the JNI call works perfectly, but it doesn’t work when I run methods sequentially.
This is my code
Output:
If I create C program from this code, and as regular C program, gcc ... && a.out -> then no error occurs. What can be reason?
Can it be because file descriptor is closed?

Answer:

The issue is that you’re treating AF_UNIX socket as AF_INET one. You can’t use sockaddr_in for AF_UNIX socket and also you can’t bind it to an IP address.
I think that you’ve made a typo in your socket definition code. Instead of
it should be

If you have better answer, please add a comment about this, thank you!

java
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Use Svelte Component as Slot

26/03/2023

Resolved: Vaadin 14.9 – Redirect on Session Destroy Event

26/03/2023

Resolved: How to separate multiple answers in one column, for multiple columns, by creating extra columns

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.