public UnixV4NativeSocket(int family, int type, int protocol) throws Exception { m_sock = socket(family, type, protocol); }
@Override public void allowFragmentation(final boolean frag) throws IOException { allowFragmentation(IPPROTO_IP, IP_MTU_DISCOVER, frag); }
@Override public int receive(NativeDatagramPacket p) { sockaddr_in in_addr = new sockaddr_in(); int[] szRef = new int[] { in_addr.size() }; ByteBuffer buf = p.getContent(); int n = recvfrom(getSock(), buf, buf.capacity(), 0, in_addr, szRef); p.setLength(n); p.setAddress(in_addr.getAddress()); p.setPort(in_addr.getPort()); return n; }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public int receive(NativeDatagramPacket p) { sockaddr_in in_addr = new sockaddr_in(); int[] szRef = new int[] { in_addr.size() }; ByteBuffer buf = p.getContent(); int n = recvfrom(getSock(), buf, buf.capacity(), 0, in_addr, szRef); p.setLength(n); p.setAddress(in_addr.getAddress()); p.setPort(in_addr.getPort()); return n; }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public int receive(NativeDatagramPacket p) { sockaddr_in in_addr = new sockaddr_in(); int[] szRef = new int[] { in_addr.size() }; ByteBuffer buf = p.getContent(); int n = recvfrom(getSock(), buf, buf.capacity(), 0, in_addr, szRef); p.setLength(n); p.setAddress(in_addr.getAddress()); p.setPort(in_addr.getPort()); return n; }
@Override public void allowFragmentation(final boolean frag) throws IOException { allowFragmentation(IPPROTO_IP, IP_MTU_DISCOVER, frag); }