Closed kuailelijuan closed 3 years ago
Hi kuailelijuan,
Your code doesn't compile. Please provide the full source code as file attachments.
It would be very helpful to understand what platform you're seeing this issue on (the error is coming from the system). Please also provide the output of java -jar junixsocket-selftest-2.3.2-jar-with-dependencies.jar
(or, even better, use the selftest jar from the current pre-release version 2.3.3).
Lastly, you have a typo in the filename (domian instead of domain).
Best, Christian
Closing due to inactivity. Please try again with the latest junixsocket version (2.3.3 or newer) and re-open this issue (with a complete code fragment) if necessary
1.exception info: java.net.SocketTimeoutException: Resource temporarily unavailable at org.newsclub.net.unix.NativeUnixSocket.read(Native Method) at org.newsclub.net.unix.AFUNIXSocketImpl$AFUNIXInputStream.read(AFUNIXSocketImpl.java:325) at java.io.InputStream.read(InputStream.java:101) at com.my.server.junixsocket.UnixSocketServer.doServeSocket(UnixSocketServer.java:101) at org.newsclub.net.unix.server.AFUNIXSocketServer$2.run(AFUNIXSocketServer.java:354) at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172) Closed: AFUNIXSocket[fd=java.io.FileDescriptor@4b545c2f;addr=org.newsclub.net.unix.AFUNIXSocketAddress[port=0;path=/user/demo/unix_domian_sock]] Active connections: 0; waiting for the next connection...
include
include <sys/socket.h>
include <sys/un.h>
int main(){ int sock; sockaddr_un s_un; int n; char buf[128];
sock = socket(AF_UNIX, SOCK_STREAM, 0); if(sock < 0){ perror("socket"); return 1; }
s_un.sun_family = AF_UNIX; strcpy(s_un.sun_path, "/user/demo/unix_domian_sock"); if(connect(sock, (sockaddr*)&s_un, sizeof(s_un)) != 0){ perror("connect"); return 1; } write(sock, "RC", 2); printf("after connect\n"); memset(buf, 0, sizeof(buf)); n = read(sock, buf, sizeof(buf)); if(n < 0){ perror("read"); return 1; }
printf("%s\n", buf); close(sock); return 0; } 3.server write by java
public static void main(String[] args) { String socketName = "/user/demo/unix_domian_sock"; try {