Closed SteveShell closed 2 years ago
Thanks for reporting, @SteveShell !
This is a very interesting bug. I had somewhat hoped that I wouldn't have to fix this, but I'm glad I spent some time on it — I learned a lot about Win32 APIs (although it came with uttering some serious expletives)
Please see if the attached binaries work for your use case.
junixsocket-dist-2.6.1-SNAPSHOT-bin.zip junixsocket-selftest.zip
Thanks for such a quick response. I appreciate it. I cheated and had my server setup attempt to connect "to it's self" as client and on failure it did the bind(). If it connects, it must be a second instance.
public void bind() throws IOException { if (serverRunning()) { throw new IOException("server already running."); } unixDomainServer.bind(endpoint); }
public boolean serverRunning() throws IOException { try (AFUNIXSocket client = AFUNIXSocket.newInstance()) { try { client.connect(endpoint); client.close(); return true; } catch (IOException e) { return false; } } }
Unfortunately I do not see any "bind()" errors in the SNAPSHOT patch. I don't see any Exceptions for the second instance.
However, there is a new behavior now. I downloaded the latest SimpleTestServer.java and when I run it a second time the first instance now gets an IOException on the accept(), which causes it to exit. The second instance then "owns" the socket and running the SimpleTestClient.java connects with the second instance.
The first instance prints out this info
server: AFUNIXServerSocket[org.newsclub.net.unix.AFUNIXSocketAddress[path=C:\Users\xxx\AppData\Local\Temp\junixsocket-test.sock]]Waiting for connection...
(sits on accept() until I run the second instance)
Exception in thread "main" java.net.SocketException: Socket is closed at org.newsclub.net.unix.AFServerSocket.accept1(AFServerSocket.java:300) at org.newsclub.net.unix.AFServerSocket.accept(AFServerSocket.java:291) at org.newsclub.net.unix.AFUNIXServerSocket.accept(AFUNIXServerSocket.java:162) at test.SimpleTestServer.main(SimpleTestServer.java:56)
The second instance acts like it is ready
server: AFUNIXServerSocket[org.newsclub.net.unix.AFUNIXSocketAddress[path=C:\Users\xxx\AppData\Local\Temp\junixsocket-test.sock]]Waiting for connection...
*Connected: @.[local=org.newsclub.net.unix.AFUNIXSocketAddress[path=C:\Users\xxx\AppData\Local\Temp\junixsocket-test.sock];remote=null]Saying hello to client @.'s response: Hello ServerNow counting to 5...write 1received 2write 2received 4write 3received 6write 4received 8write 5received 10write 6write -123 (end of numbers)Waiting for connection...*
On Thu, Oct 20, 2022 at 2:49 PM Dr. Christian Kohlschütter < @.***> wrote:
Thanks for reporting, @SteveShell https://github.com/SteveShell !
This is a very interesting bug. I had somewhat hoped that I wouldn't have to fix this, but I'm glad I spent some time on it — I learned a lot about Win32 APIs (although it came with uttering some serious expletives)
Please see if the attached binaries work for your use case.
junixsocket-dist-2.6.1-SNAPSHOT-bin.zip https://github.com/kohlschutter/junixsocket/files/9833464/junixsocket-dist-2.6.1-SNAPSHOT-bin.zip junixsocket-selftest.zip https://github.com/kohlschutter/junixsocket/files/9833473/junixsocket-selftest.zip
— Reply to this email directly, view it on GitHub https://github.com/kohlschutter/junixsocket/issues/121#issuecomment-1286058312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHSUMOU5KHV5XJXST353KDWEGO5HANCNFSM6AAAAAARIL4B5Q . You are receiving this because you were mentioned.Message ID: @.***>
This program determines whether junixsocket is supported on the current platform. The final line should say whether the selftest passed or failed.
If the selftest failed, please visit https://github.com/kohlschutter/junixsocket/issues and file a new bug report with the output below.
junixsocket selftest version 2.6.1-SNAPSHOT
Git properties:
git.build.version: 2.6.1-SNAPSHOT git.commit.id.abbrev: b93f433 git.commit.id.describe: junixsocket-2.6.0-18-gb93f433 git.commit.id.full: b93f43349c5e9ae9e6ce45874a7a53cee3857b4d git.commit.time: 2022-10-20T21:37:12+02:00 git.dirty: false
System properties:
awt.toolkit: sun.awt.windows.WToolkit file.encoding: Cp1252 file.encoding.pkg: sun.io file.separator: \ java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment java.awt.printerjob: sun.awt.windows.WPrinterJob java.class.path: junixsocket-selftest-2.6.1-SNAPSHOT-jar-with-dependencies.jar java.class.version: 52.0 java.endorsed.dirs: C:\Program Files\Java\jdk1.8.0_191\jre\lib\endorsed java.ext.dirs: C:\Program Files\Java\jdk1.8.0_191\jre\lib\ext;C:\Windows\Sun\Java\lib\ext java.home: C:\Program Files\Java\jdk1.8.0_191\jre
java.runtime.name: Java(TM) SE Runtime Environment java.runtime.version: 1.8.0_191-b12 java.specification.name: Java Platform API Specification java.specification.vendor: Oracle Corporation java.specification.version: 1.8 java.vendor: Oracle Corporation java.vendor.url: http://java.oracle.com/ java.vendor.url.bug: http://bugreport.sun.com/bugreport/ java.version: 1.8.0_191 java.vm.info: mixed mode java.vm.name: Java HotSpot(TM) 64-Bit Server VM java.vm.specification.name: Java Virtual Machine Specification java.vm.specification.vendor: Oracle Corporation java.vm.specification.version: 1.8 java.vm.vendor: Oracle Corporation java.vm.version: 25.191-b12 line.separator: \r\n os.arch: amd64 os.name: Windows 10 os.version: 10.0 path.separator: ; sun.arch.data.model: 64 sun.boot.class.path: C:\Program Files\Java\jdk1.8.0_191\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_191\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_191\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_191\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_191\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_191\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_191\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_191\jre\classes sun.boot.library.path: C:\Program Files\Java\jdk1.8.0_191\jre\bin sun.cpu.endian: little sun.cpu.isalist: amd64 sun.desktop: windows sun.io.unicode.encoding: UnicodeLittle sun.java.command: junixsocket-selftest-2.6.1-SNAPSHOT-jar-with-dependencies.jar sun.java.launcher: SUN_STANDARD sun.jnu.encoding: Cp1252 sun.management.compiler: HotSpot 64-Bit Tiered Compilers sun.os.patch.level: sun.stderr.encoding: cp437 user.country: US user.dir: junixsocket-dist-2.6.1-SNAPSHOT user.language: en user.script: user.timezone: user.variant:
AFSocket.isSupported: true
AFUNIXSocket.isSupported: true
Testing "junixsocket-common"... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testParseFail()... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testSchemesAvailable()... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testGeneric()... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testSocatString()... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testSocketURI()... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testServiceRangeURI()... Testing "junixsocket-common"... AFTIPCSocketAddressTest.testServiceURI()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testSchemesAvailable()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testSocatString()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testURITemplateWithPortNumber()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testURITemplate()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testHttpUnix()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testUnixScheme()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testFileScheme()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testAbstractNamespace()... Testing "junixsocket-common"... AFUNIXSocketAddressTest.testParseURIandBack()... Testing "junixsocket-common"... AcceptTimeoutTest.testCatchTimeout()... Testing "junixsocket-common"... AcceptTimeoutTest.testTimeoutAfterDelay()... Testing "junixsocket-common"... AcceptTimeoutTest.testAcceptWithoutBindToService()... Testing "junixsocket-common"... AvailableTest.testAvailableAtClient()... Testing "junixsocket-common"... AvailableTest.testAvailableAtServer()... Testing "junixsocket-common"... BufferOverflowTest.writeOverflow()... Testing "junixsocket-common"... BufferOverflowTest.readUpTo()... Testing "junixsocket-common"... BufferOverflowTest.readOutOfBounds()... Testing "junixsocket-common"... CancelAcceptTest.issue6test1()... Testing "junixsocket-common"... EndOfFileTest.clientWriteToSocketClosedByClient()... Testing "junixsocket-common"... EndOfFileTest.clientWriteToSocketClosedByServer()... Testing "junixsocket-common"... EndOfFileTest.bidirectionalSanity()... Testing "junixsocket-common"... EndOfFileTest.serverWriteToSocketClosedByClient()... Testing "junixsocket-common"... EndOfFileTest.serverWriteToSocketClosedByServer()... Testing "junixsocket-common"... EndOfFileTest.clientReadEof()... Testing "junixsocket-common"... EndOfFileTest.serverReadEof()... Testing "junixsocket-common"... FileDescriptorCastTest.testInvalidFileDescriptor()... Testing "junixsocket-common"... FileDescriptorCastTest.testPipe()... Testing "junixsocket-common"... FileDescriptorCastTest.testAvailableTypes()... Testing "junixsocket-common"... FileDescriptorCastTest.testStdout()... Testing "junixsocket-common"... FileDescriptorCastTest.testRandomAccessFile()... Testing "junixsocket-common"... FileDescriptorCastTest.testUnconnectedServerAsSocket()... Testing "junixsocket-common"... FileDescriptorCastTest.testSocketPorts()... Testing "junixsocket-common"... FileDescriptorCastTest.testServer()... Testing "junixsocket-common"... InetAddressTest.testFromToBytes()... Testing "junixsocket-common"... InetAddressTest.testHostnameString()... Testing "junixsocket-common"... InetAddressTest.testIsLoopbackAddress()... Testing "junixsocket-common"... InetAddressTest.testHostnameStringEndsWithJunixSocket()... Testing "junixsocket-common"... PeerCredentialsTest.testSocketsSameProcess()... Supported credentials: pid Unsupported credentials: uid gid additional_gids uuid Testing "junixsocket-common"... PipeTest.testPipe()... Testing "junixsocket-common"... PipeTest.testPipeRecvHang()... Testing "junixsocket-common"... ReadWriteTest.testReceiveWithByteArraySendByteForByte()... Testing "junixsocket-common"... ReadWriteTest.testReceiveWithByteArraySendWithByteArray()... Testing "junixsocket-common"... ReadWriteTest.testReceiveDataByteForByteSendByteForByte()... Testing "junixsocket-common"... ReadWriteTest.testReceiveDataByteForByteSendWithByteArray()... Testing "junixsocket-common"... SelectorTest.testNonBlockingAccept()... Testing "junixsocket-common"... SelectorTest.testClosedSelectorSelect()... Testing "junixsocket-common"... SelectorTest.testClosedSelectorWakeup()... Testing "junixsocket-common"... SelectorTest.testCancelSelect()... Testing "junixsocket-common"... SelectorTest.testConnectionCloseImmediateClientDisconnect()... Testing "junixsocket-common"... SelectorTest.testConnectionCloseImmediateClientDisconnectKeepLooping()... Testing "junixsocket-common"... SelectorTest.testConnectionCloseEventualClientDisconnectKeepLooping()... Testing "junixsocket-common"... SelectorTest.testConnectionCloseEventualClientDisconnect()... Testing "junixsocket-common"... ServerSocketCloseTest.testUnblockAcceptsWithSoTimeout()... Testing "junixsocket-common"... ServerSocketCloseTest.testUnblockAcceptsWithoutSoTimeout()... Testing "junixsocket-common"... ServerSocketTest.testUnboundServerSocket()... Testing "junixsocket-common"... ServerSocketTest.testBindBadArguments()... Testing "junixsocket-common"... ServerSocketTest.testCloseable()... Testing "junixsocket-common"... ServerSocketTest.testSupported()... Testing "junixsocket-common"... SocketAddressTest.testInetAddress()... Testing "junixsocket-common"... SocketAddressTest.testPath()... Testing "junixsocket-common"... SocketAddressTest.testPort()... Testing "junixsocket-common"... SocketAddressTest.testEmptyAddress()... Testing "junixsocket-common"... SocketAddressTest.testLegacyConstructor()... Testing "junixsocket-common"... SocketAddressTest.testByteConstructor()... Testing "junixsocket-common"... SocketAddressTest.testAbstractNamespace()... Testing "junixsocket-common"... SocketChannelTest.testDoubleBindAddressReusable()... Testing "junixsocket-common"... SocketChannelTest.testDoubleBindAddressNotReusable()... Testing "junixsocket-common"... SocketChannelTest.testNonBlockingConnect()... Testing "junixsocket-common"... SocketFactoryTest.testURISchemeCeateSocketWithInvalidHostname()... Testing "junixsocket-common"... SocketFactoryTest.testURISchemeCeateSocketWithIllegalArguments()... Testing "junixsocket-common"... SocketFactoryTest.testURISchemeCeateSocketThenConnect()... Testing "junixsocket-common"... SocketFactoryTest.testURISchemeCeateSocketWithHostnameValidCases()... Testing "junixsocket-common"... SocketFactoryTest.testSystemProperty()... Testing "junixsocket-common"... SocketFactoryTest.testFactoryArg()... Testing "junixsocket-common"... SocketPairTest.testSocketPair()... Testing "junixsocket-common"... SocketTest.testConnectBadArguments()... Testing "junixsocket-common"... SocketTest.testBindBadArguments()... Testing "junixsocket-common"... SocketTest.testCloseable()... Testing "junixsocket-common"... SocketTest.testUnconnectedSocket()... Testing "junixsocket-common"... SocketTest.testMain()... org.newsclub.net.unix.AFUNIXSocket.isSupported(): true CAPABILITY_PEER_CREDENTIALS: true CAPABILITY_ANCILLARY_MESSAGES: false CAPABILITY_FILE_DESCRIPTORS: false CAPABILITY_ABSTRACT_NAMESPACE: false CAPABILITY_UNIX_DATAGRAMS: false CAPABILITY_NATIVE_SOCKETPAIR: false CAPABILITY_FD_AS_REDIRECT: false CAPABILITY_TIPC: false CAPABILITY_UNIX_DOMAIN: true CAPABILITY_VSOCK: false CAPABILITY_VSOCK_DGRAM: false Testing "junixsocket-common"... SocketTest.testLoadedLibrary()... Testing "junixsocket-common"... SocketTest.testSupports()... Testing "junixsocket-common"... SocketTest.testVersion()... Testing "junixsocket-common"... SocketTest.testReceivedFileDescriptorsUnconnected()... Testing "junixsocket-common"... SocketTest.testSupported()... Testing "junixsocket-common"... SoTimeoutTest.issue14Fail()... Testing "junixsocket-common"... SoTimeoutTest.issue14Pass()... Testing "junixsocket-common"... SoTimeoutTest.testSocketTimeoutExceptionRead()... Testing "junixsocket-common"... SoTimeoutTest.testSocketTimeoutExceptionWrite()... Testing "junixsocket-common"... TcpNoDelayTest.testDefaultImpl()... Testing "junixsocket-common"... TcpNoDelayTest.testStrictImpl()... Testing "junixsocket-common"... ThroughputTest.testSocket()... Testing "junixsocket-common"... ThroughputTest.testSocketChannel()... Testing "junixsocket-common"... ThroughputTest.testSocketChannelDirectBuffer()... Testing "junixsocket-common"... done
. '-- JUnit Jupiter [OK] +-- AFTIPCSocketAddressTest [OK] | +-- testParseFail() [OK] | +-- testSchemesAvailable() [OK] | +-- testGeneric() [OK] | +-- testSocatString() [OK] | +-- testSocketURI() [OK] | +-- testServiceRangeURI() [OK] | '-- testServiceURI() [OK] +-- AFUNIXSocketAddressTest [OK] | +-- testSchemesAvailable() [OK] | +-- testSocatString() [OK] | +-- testURITemplateWithPortNumber() [OK] | +-- testURITemplate() [OK] | +-- testHttpUnix() [OK] | +-- testUnixScheme() [OK] | +-- testFileScheme() [OK] | +-- testAbstractNamespace() [OK] | '-- testParseURIandBack() [OK] +-- AbstractNamespaceTest [S] Missing capabilities: [CAPABILITY_ABSTRACT_NAMESPACE] +-- AcceptTimeoutTest [OK] | +-- testCatchTimeout() [OK] | +-- testTimeoutAfterDelay() [OK] | '-- testAcceptWithoutBindToService() [OK] +-- AvailableTest [OK] | +-- testAvailableAtClient() [OK] | '-- testAvailableAtServer() [OK] +-- BufferOverflowTest [OK] | +-- writeOverflow() [OK] | +-- readUpTo() [OK] | '-- readOutOfBounds() [OK] +-- CancelAcceptTest [OK] | '-- issue6test1() [OK] +-- DatagramSocketTest [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- EndOfFileTest [OK] | +-- clientWriteToSocketClosedByClient() [OK] | +-- clientWriteToSocketClosedByServer() [OK] | +-- bidirectionalSanity() [OK] | +-- serverWriteToSocketClosedByClient() [OK] | +-- serverWriteToSocketClosedByServer() [OK] | +-- clientReadEof() [OK] | '-- serverReadEof() [OK] +-- FileDescriptorCastTest [OK] | +-- testInvalidFileDescriptor() [OK] | +-- testPipe() [OK] | +-- testAvailableTypes() [OK] | +-- testStdout() [OK] | '-- testRandomAccessFile() [OK] +-- FileDescriptorCastTest [OK] | +-- testUnconnectedServerAsSocket() [OK] | +-- testSocketPairNative() [S] Missing capabilities: [CAPABILITY_NATIVE_SOCKETPAIR] | +-- testDatagramFileChannel() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] | +-- testSocketPair() [S] Missing capabilities: [CAPABILITY_NATIVE_SOCKETPAIR] | +-- testDatagramSocket() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] | +-- testSocketPorts() [OK] | +-- testDatagramPorts() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] | +-- testForkedVMRedirectStdin() [S] Missing capabilities: [CAPABILITY_FD_AS_REDIRECT] | '-- testServer() [OK] +-- FileDescriptorsTest [S] Missing capabilities: [CAPABILITY_FILE_DESCRIPTORS] +-- InetAddressTest [OK] | +-- testFromToBytes() [OK] | +-- testHostnameString() [OK] | +-- testIsLoopbackAddress() [OK] | '-- testHostnameStringEndsWithJunixSocket() [OK] +-- PeerCredentialsTest [OK] | +-- testSocketsSameProcess() [OK] | '-- testDatagramSocket() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- PipeTest [OK] | +-- testPipe() [OK] | '-- testPipeRecvHang() [OK] +-- ReadWriteTest [OK] | +-- testReceiveWithByteArraySendByteForByte() [OK] | +-- testReceiveWithByteArraySendWithByteArray() [OK] | +-- testReceiveDataByteForByteSendByteForByte() [OK] | '-- testReceiveDataByteForByteSendWithByteArray() [OK] +-- SelectorTest [OK] | +-- testNonBlockingAccept() [OK] | +-- testClosedSelectorSelect() [OK] | +-- testClosedSelectorWakeup() [OK] | +-- testCancelSelect() [OK] | +-- testConnectionCloseImmediateClientDisconnect() [OK] | +-- testConnectionCloseImmediateClientDisconnectKeepLooping() [OK] | +-- testConnectionCloseEventualClientDisconnectKeepLooping() [OK] | '-- testConnectionCloseEventualClientDisconnect() [OK] +-- ServerSocketCloseTest [OK] | +-- testUnblockAcceptsWithSoTimeout() [OK] | '-- testUnblockAcceptsWithoutSoTimeout() [OK] +-- ServerSocketTest [OK] | +-- testUnboundServerSocket() [OK] | +-- testBindBadArguments() [OK] | +-- testCloseable() [OK] | '-- testSupported() [OK] +-- SocketAddressTest [OK] | +-- testInetAddress() [OK] | +-- testPath() [OK] | +-- testPort() [OK] | +-- testEmptyAddress() [OK] | +-- testLegacyConstructor() [OK] | +-- testByteConstructor() [OK] | '-- testAbstractNamespace() [OK] +-- SocketChannelTest [OK] | +-- testDoubleBindAddressReusable() [OK] | +-- testDoubleBindAddressNotReusable() [OK] | '-- testNonBlockingConnect() [OK] +-- SocketFactoryTest [OK] | +-- testURISchemeCeateSocketWithInvalidHostname() [OK] | +-- testURISchemeCeateSocketWithIllegalArguments() [OK] | +-- testURISchemeCeateSocketThenConnect() [OK] | +-- testURISchemeCeateSocketWithHostnameValidCases() [OK] | +-- testSystemProperty() [OK] | '-- testFactoryArg() [OK] +-- SocketPairTest [OK] | +-- testDatagramPair() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] | '-- testSocketPair() [OK] +-- SocketTest [OK] | +-- testConnectBadArguments() [OK] | +-- testBindBadArguments() [OK] | +-- testCloseable() [OK] | +-- testUnconnectedSocket() [OK] | +-- testMain() [OK] | +-- testLoadedLibrary() [OK] | +-- testSupports() [OK] | +-- testVersion() [OK] | +-- testReceivedFileDescriptorsUnconnected() [OK] | '-- testSupported() [OK] +-- SoTimeoutTest [OK] | +-- issue14Fail() [OK] | +-- issue14Pass() [OK] | +-- testSocketTimeoutExceptionRead() [OK] | '-- testSocketTimeoutExceptionWrite() [OK] +-- StandardSocketOptionsTest [OK] | +-- testUnconnectedServerSocketOptions() [S] This test requires Java 9 or later | '-- testSocketOptions() [S] This test requires Java 9 or later +-- TcpNoDelayTest [OK] | +-- testDefaultImpl() [OK] | '-- testStrictImpl() [OK] '-- ThroughputTest [OK] +-- testDatagramChannel() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- testDatagramChannelDirect() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- testDatagramChannelNonBlocking() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- testDatagramChannelNonBlockingDirect() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- testDatagramPacket() [S] Missing capabilities: [CAPABILITY_UNIX_DATAGRAMS] +-- testSocket() [OK] +-- testSocketChannel() [OK] '-- testSocketChannelDirectBuffer() [OK]
Test run finished after 6034 ms [ 29 containers found ] [ 3 containers skipped ] [ 26 containers started ] [ 0 containers aborted ] [ 26 containers successful ] [ 0 containers failed ] [ 131 tests found ] [ 30 tests skipped ] [ 101 tests started ] [ 0 tests aborted ] [ 101 tests successful ] [ 0 tests failed ]
Testing "junixsocket-tipc"... Testing "junixsocket-tipc"... done
. '-- JUnit Jupiter [OK] +-- AcceptTimeoutTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- AFTIPCTopologyWatcherTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- AncillaryMessageTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- AvailableTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- BufferOverflowTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- CancelAcceptTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- DatagramSocketTest [S] Missing capabilities: [CAPABILITY_TIPC, CAPABILITY_UNIX_DATAGRAMS] +-- EndOfFileTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- ReadWriteTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- SelectorTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- ServerSocketCloseTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- ServerSocketTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- SocketChannelTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- SocketOptionsTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- SocketPairTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- SocketTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- SoTimeoutTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- StandardSocketOptionsTest [S] Missing capabilities: [CAPABILITY_TIPC] +-- TcpNoDelayTest [S] Missing capabilities: [CAPABILITY_TIPC] '-- ThroughputTest [S] Missing capabilities: [CAPABILITY_TIPC]
Test run finished after 14 ms [ 21 containers found ] [ 20 containers skipped ] [ 1 containers started ] [ 0 containers aborted ] [ 1 containers successful ] [ 0 containers failed ] [ 80 tests found ] [ 80 tests skipped ] [ 0 tests started ] [ 0 tests aborted ] [ 0 tests successful ] [ 0 tests failed ]
Testing "junixsocket-vsock"... Testing "junixsocket-vsock"... AFVSOCKExtensionsTest.testGetLocalID()... Testing "junixsocket-vsock"... done
. '-- JUnit Jupiter [OK] +-- AFVSOCKExtensionsTest [OK] | '-- testGetLocalID() [OK] +-- AcceptTimeoutTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- AvailableTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- BufferOverflowTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- CancelAcceptTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- DatagramSocketTest [S] Missing capabilities: [CAPABILITY_VSOCK, CAPABILITY_VSOCK_DGRAM] +-- EndOfFileTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- ReadWriteTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- SelectorTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- ServerSocketCloseTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- ServerSocketTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- SocketChannelTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- SocketOptionsTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- SocketPairTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- SocketTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- SoTimeoutTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- StandardSocketOptionsTest [S] Missing capabilities: [CAPABILITY_VSOCK] +-- TcpNoDelayTest [S] Missing capabilities: [CAPABILITY_VSOCK] '-- ThroughputTest [S] Missing capabilities: [CAPABILITY_VSOCK]
Test run finished after 18 ms [ 20 containers found ] [ 18 containers skipped ] [ 2 containers started ] [ 0 containers aborted ] [ 2 containers successful ] [ 0 containers failed ] [ 76 tests found ] [ 75 tests skipped ] [ 1 tests started ] [ 0 tests aborted ] [ 1 tests successful ] [ 0 tests failed ]
Testing "junixsocket-rmi"... Testing "junixsocket-rmi"... RegistryTest.testDoubleCreateRegistry()... Testing "junixsocket-rmi"... RegistryTest.testExportAndBind()... Testing "junixsocket-rmi"... RemoteCloseableTest.testRemoteCloseableWithANotCloseableThing()... Testing "junixsocket-rmi"... RemoteCloseableTest.testRemoteCloseableWithACloseableThing()... Testing "junixsocket-rmi"... RMIPeerCredentialsTest.testRemotePeerCredentials()... Testing "junixsocket-rmi"... JunixsocketVersionTest.testVersion()... Testing "junixsocket-rmi"... done
. '-- JUnit Jupiter [OK] +-- RegistryTest [OK] | +-- testDoubleCreateRegistry() [OK] | '-- testExportAndBind() [OK] +-- RemoteCloseableTest [OK] | +-- testRemoteCloseableWithANotCloseableThing() [OK] | '-- testRemoteCloseableWithACloseableThing() [OK] +-- RemoteFileDescriptorTest [S] Missing capabilities: [CAPABILITY_FILE_DESCRIPTORS] +-- RMIPeerCredentialsTest [OK] | '-- testRemotePeerCredentials() [OK] '-- JunixsocketVersionTest [OK] '-- testVersion() [OK]
Test run finished after 411 ms [ 6 containers found ] [ 1 containers skipped ] [ 5 containers started ] [ 0 containers aborted ] [ 5 containers successful ] [ 0 containers failed ] [ 12 tests found ] [ 6 tests skipped ] [ 6 tests started ] [ 0 tests aborted ] [ 6 tests successful ] [ 0 tests failed ]
Skipping optional module: junixsocket-common.JavaInet; enable by launching with -Dselftest.enable-module.junixsocket-common.JavaInet=true
Selftest results: PASS junixsocket-common 101/131 (30 skipped) PASS junixsocket-tipc 0/80 (80 skipped) PASS junixsocket-vsock 1/76 (75 skipped) PASS junixsocket-rmi 6/12 (6 skipped)
Supported capabilities: [CAPABILITY_PEER_CREDENTIALS, CAPABILITY_UNIX_DOMAIN] Unsupported capabilities: [CAPABILITY_ANCILLARY_MESSAGES, CAPABILITY_FILE_DESCRIPTORS, CAPABILITY_ABSTRACT_NAMESPACE, CAPABILITY_UNIX_DATAGRAMS, CAPABILITY_NATIVE_SOCKETPAIR, CAPABILITY_FD_AS_REDIRECT, CAPABILITY_TIPC, CAPABILITY_VSOCK, CAPABILITY_VSOCK_DGRAM]
Selftest PASSED
Hi @SteveShell,
It somewhat looks like the code is doing what I expected, but not exactly what you expected. I think we can clarify this.
First, try the updated code below (see commit e10cf8f where I made additional changes to the code — I also added comments to SimpleTestServer that may clarify what it's expected to do): junixsocket-dist-2.6.1-SNAPSHOT-bin.zip
By default, junixsocket tries to "steal" an already-bound AF_UNIX socket. This is mostly necessary to work-around invalid socket files that are on the file system but no longer connected. It also allows for a relatively clean server-restart. When we re-bind the socket path to a new server, we need to "wake up" any pending accept-s from the previous server. On UNIX, junixsocket code identifies this situation by comparing inode numbers. These aren't available on Windows but now the new code checks for socket file creation date (which is, ironically, not properly set by default in Win32 code, so junixsocket does some extra work now).
In both cases, we "knock" on the old bound socket (which now lives under a temporary path). If a connection is established, the server will detect the situation and close. If no connection is established, no harm is done.
You may change this behavior by setting "setReuseAddress(false)" (see SimpleTestServer code). In that case, trying to rebind will throw an exception, so there's no need to connect from your code.
Let me know if this clarifies the behavior. If you're still seeing something you believe is not correct, please insist and send me some reproducible test code (full java source files please), I will try my best to understand and/or fix it.
Please test with the most recent build: junixsocket-selftest-2.6.1-20221023.200716-2-jar-with-dependencies.jar and junixsocket-dist-2.6.1-SNAPSHOT-bin.zip
Assuming this is fixed. 2.6.1 will be released tomorrow. Please verify with the above snapshot build, and reopen this bug if necessary. Thanks again for reporting!
Thanks! Earlier this weekend I had been writing a long reply, but I'm pleased you closed it out, and I will get the 2.6.1 and use that version. I appreciate your great vision on junixsocket. Hopefully for you it was an enjoyable jaunt down the WIN32 lane. Cheers, Steve Shell
On Tue, Oct 25, 2022 at 10:39 AM Dr. Christian Kohlschütter < @.***> wrote:
Closed #121 https://github.com/kohlschutter/junixsocket/issues/121 as completed.
— Reply to this email directly, view it on GitHub https://github.com/kohlschutter/junixsocket/issues/121#event-7664851126, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHSUMPY3N4XFX2HBPOVORLWE75LRANCNFSM6AAAAAARIL4B5Q . You are receiving this because you were assigned.Message ID: @.***>
Describe the bug Using Windows 10, the "server.bind()" command does not return any error with multiple test servers using the same file and port or no defined port. The TestSampleServer runs and sits at the "accept()", but only the last one run binds and owns the socket. Or even the pattern to run is "Server/Client (printout) --- Server Server (printout) -- Client" the last Server run gets the next Client connections. None of the "server" methods return any indication that the socket is "bound".
To Reproduce Steps to reproduce the behavior:
Expected behavior Run a second TestSampleServer, the server.bind() should throw the IOException " if the bind operation fails, or if the socketis already bound."
Output/Screenshots If applicable, add console output/screenshots to help explain your problem.
Stop, run two TestSampleServer concurrently
Environment (please complete the following information): Edition Windows 10 Pro Version 21H2 Installed on 4/15/2021 OS build 19044.2130 Experience Windows Feature Experience Pack 120.2212.4180.0
Processor AMD Ryzen Threadripper 2990WX 32-Core Processor 3.00 GHz Installed RAM 128 GB (128 GB usable) System type 64-bit operating system, x64-based processor
Please also add the output of
java -jar junixsocket-selftest-x.y.z-SNAPSHOT-jar-with-dependencies.jar
(x.y.z being the latest version, e.g., 2.3.3). — The selftest jar is available from the junixsocket-dist package in the Release section. This program determines whether junixsocket is supported on the current platform. The final line should say whether the selftest passed or failed.If the selftest failed, please visit https://github.com/kohlschutter/junixsocket/issues and file a new bug report with the output below.