|
23 | 23 | import java.nio.ByteBuffer; |
24 | 24 |
|
25 | 25 | import com.github.dockerjava.transport.FileDescriptor.Handle; |
| 26 | +import com.sun.jna.ptr.IntByReference; |
26 | 27 | import com.sun.jna.LastErrorException; |
| 28 | +import com.sun.jna.Pointer; |
27 | 29 | import com.sun.jna.Native; |
28 | 30 | import com.sun.jna.Platform; |
29 | 31 |
|
@@ -66,6 +68,10 @@ public abstract class DomainSocket extends AbstractSocket { |
66 | 68 |
|
67 | 69 | private FileDescriptor open(String path) { |
68 | 70 | int handle = socket(PF_LOCAL, SOCK_STREAM, 0); |
| 71 | + setsockopt(handle, 1/*SOL_SOCKET*/, 20/*SO_RCVTIMEO*/, new IntByReference(1000).getPointer(), 4); |
| 72 | + setsockopt(handle, 1/*SOL_SOCKET*/, 21/*SO_SNDTIMEO*/, new IntByReference(1000).getPointer(), 4); |
| 73 | + setsockopt(handle, 1/*SOL_SOCKET*/, 66/*SO_RCVTIMEO_NEW*/, new IntByReference(1000).getPointer(), 4); |
| 74 | + setsockopt(handle, 1/*SOL_SOCKET*/, 67/*SO_SNDTIMEO_NEW*/, new IntByReference(1000).getPointer(), 4); |
69 | 75 | connect(path, handle); |
70 | 76 | return new FileDescriptor(handle, this::close); |
71 | 77 | } |
@@ -119,6 +125,8 @@ public void close() throws IOException { |
119 | 125 |
|
120 | 126 | private native int socket(int domain, int type, int protocol) throws LastErrorException; |
121 | 127 |
|
| 128 | + private static native int setsockopt(int fd, int level, int option, Pointer value, int len) throws LastErrorException; |
| 129 | + |
122 | 130 | private native int read(int fd, ByteBuffer buffer, int count) throws LastErrorException; |
123 | 131 |
|
124 | 132 | private native int write(int fd, ByteBuffer buffer, int count) throws LastErrorException; |
|
0 commit comments