java.lang.Object
net.i2p.sam.SAMv3DatagramServer
All Implemented Interfaces:
Handler

class SAMv3DatagramServerextends Object implements Handler
This is the thread listening on 127.0.0.1:7655 or as specified by sam.udp.host and sam.udp.port properties. This is used for both repliable and raw datagrams.
  • Field Details

    • _server

      private final DatagramChannel _server
      The UDP socket the clients connect to.
    • _listener

      private final Thread _listener
      Thread reading from the socket.
    • _parent

      private final SAMBridge _parent
      The bridge serving the destination.
    • _host

      private final String _host
      The host the socket is bound to.
    • _port

      private final int _port
      The port the socket is bound to.
  • Constructor Details

    • SAMv3DatagramServer

      public SAMv3DatagramServer(SAMBridge parent, String host, int port, Properties props) throws IOException
      Does not start listener. Caller must call start().
      Parameters:
      parent - may be null
      host - the local address to bind the datagram channel to
      port - the local port to bind, 0 to let the system choose
      props - configuration properties (reserved for future use)
      Throws:
      IOException - if the channel cannot be opened or the local address cannot be bound
  • Method Details

    • start

      public void start()
      Only call once.
    • stopHandling

      public void stopHandling()
      Cannot be restarted.
      Specified by:
      stopHandling in interface Handler
    • send

      public void send(SocketAddress addr, ByteBuffer msg) throws IOException
      Writes one datagram to the channel at the given address.
      Parameters:
      addr - the destination to deliver the datagram to
      msg - the datagram to send, positioned at its first byte and consumed by this call
      Throws:
      IOException - if the datagram cannot be written to the channel
    • getHost

      public String getHost()
      The host this server listens on, as passed to the constructor and registered with the port mapper so clients can find it.
      Returns:
      the local host address this server was bound to
    • getPort

      public int getPort()
      The port this server listens on, as passed to the constructor and registered with the port mapper so clients can find it.
      Returns:
      the local port this server was bound to