use of io.netty.channel.unix.PeerCredentials in project netty by netty.
the class KQueueSocketTest method testPeerCreds.
@Test
public void testPeerCreds() throws IOException {
BsdSocket s1 = BsdSocket.newSocketDomain();
BsdSocket s2 = BsdSocket.newSocketDomain();
try {
DomainSocketAddress dsa = UnixTestUtils.newDomainSocketAddress();
s1.bind(dsa);
s1.listen(1);
assertTrue(s2.connect(dsa));
byte[] addr = new byte[64];
s1.accept(addr);
PeerCredentials pc = s1.getPeerCredentials();
assertNotEquals(pc.uid(), -1);
} finally {
s1.close();
s2.close();
}
}
use of io.netty.channel.unix.PeerCredentials in project netty by netty.
the class KQueueSocketTest method testPeerPID.
@Test
public void testPeerPID() throws IOException {
BsdSocket s1 = BsdSocket.newSocketDomain();
BsdSocket s2 = BsdSocket.newSocketDomain();
try {
DomainSocketAddress dsa = UnixTestUtils.newDomainSocketAddress();
s1.bind(dsa);
s1.listen(1);
// PID of client socket is expected to be 0 before connection
assertEquals(0, s2.getPeerCredentials().pid());
assertTrue(s2.connect(dsa));
byte[] addr = new byte[64];
int clientFd = s1.accept(addr);
assertNotEquals(-1, clientFd);
PeerCredentials pc = new BsdSocket(clientFd).getPeerCredentials();
assertNotEquals(0, pc.pid());
assertNotEquals(0, s2.getPeerCredentials().pid());
// Server socket FDs should not have pid field set:
assertEquals(0, s1.getPeerCredentials().pid());
} finally {
s1.close();
s2.close();
}
}
use of io.netty.channel.unix.PeerCredentials in project netty by netty.
the class EpollSocketTest method testPeerCreds.
@Test
public void testPeerCreds() throws IOException {
LinuxSocket s1 = LinuxSocket.newSocketDomain();
LinuxSocket s2 = LinuxSocket.newSocketDomain();
try {
DomainSocketAddress dsa = UnixTestUtils.newDomainSocketAddress();
s1.bind(dsa);
s1.listen(1);
assertTrue(s2.connect(dsa));
byte[] addr = new byte[64];
s1.accept(addr);
PeerCredentials pc = s1.getPeerCredentials();
assertNotEquals(pc.uid(), -1);
} finally {
s1.close();
s2.close();
}
}
Aggregations