kohlschutter / junixsocket

Unix Domain Sockets in Java 7 and newer (AF_UNIX), AF_TIPC, AF_VSOCK, and more
Apache License 2.0
438 stars 114 forks source link

How to connect to UDP socket #73

Closed zJudGenie closed 3 years ago

zJudGenie commented 5 years ago

Hi, I started using unix socket yesterday, i tried connect to a SOCK_DGRAM type socket created from hostapd using the code socket(PF_UNIX, SOCK_DGRAM, 0) but when i try to connect from junixsocket i receive the error java.net.SocketException: Protocol wrong type for socket i already tried to change socket file path and permission like #66 issue said but nothing so I think that junixsocket is trying to use TCP protocol instead of UDP, i tried to do nc -U /tmp/hostapd/wlan0 and i receive same error Protocol wrong type for socket but if I add the parameter -u that stands for UDP mode all works well Thanks for all the answers

kohlschuetter commented 4 years ago

Datagram sockets are currently not supported. What's your use case?

sly010 commented 4 years ago

+1

Use case is low latency inter process event handling. It would be nice not having to frame messages.

zJudGenie commented 4 years ago

Datagram sockets are currently not supported. What's your use case?

As @sly010 said I use datagram socket for IPC with Hostapd

kohlschuetter commented 3 years ago

Thanks for reporting the enhancement request!

Starting with version 2.4.0, junixsocket supports AF_UNIX datagram sockets. See AFUNIXDatagramChannel / AFUNIXDatagramSocket / AFUNIXSelectorProvider for details.