use of io.netty.channel.unix.Socket in project netty by netty.
the class SocketTest method testDoubleCloseDoesNotThrow.
@Test
public void testDoubleCloseDoesNotThrow() throws IOException {
Socket socket = Socket.newSocketStream();
socket.close();
socket.close();
}
use of io.netty.channel.unix.Socket in project netty by netty.
the class LinuxSocketTest method testUnixDomainSocketTooLongPathFails.
@Test
public void testUnixDomainSocketTooLongPathFails() throws IOException {
// Most systems has a limit for UDS path of 108, 255 is generally too long.
StringBuilder socketPath = new StringBuilder("/tmp/");
while (socketPath.length() < 255) {
socketPath.append(UUID.randomUUID());
}
final DomainSocketAddress domainSocketAddress = new DomainSocketAddress(socketPath.toString());
final Socket socket = Socket.newSocketDomain();
try {
Exception exception = Assertions.assertThrows(NativeIoException.class, new Executable() {
@Override
public void execute() throws Throwable {
socket.bind(domainSocketAddress);
}
});
Assertions.assertTrue(exception.getMessage().contains("too long"));
} finally {
socket.close();
}
}
use of io.netty.channel.unix.Socket in project netty by netty.
the class EpollDatagramChannelTest method testActiveHasLocalAddress.
@Test
public void testActiveHasLocalAddress() throws IOException {
Socket socket = Socket.newSocketDgram();
EpollDatagramChannel channel = new EpollDatagramChannel(socket.intValue());
InetSocketAddress localAddress = channel.localAddress();
assertTrue(channel.active);
assertNotNull(localAddress);
assertEquals(socket.localAddress(), localAddress);
channel.fd().close();
}
Aggregations