Class TcpSocketTransportFactory

java.lang.Object
com.example.common.transport.tcp.TcpSocketTransportFactory
All Implemented Interfaces:
TransportFactory

public class TcpSocketTransportFactory extends Object implements TransportFactory
The TcpSocketTransportFactory class implements the TransportFactory interface for creating TCP socket listeners and connections.
  • Constructor Details

    • TcpSocketTransportFactory

      public TcpSocketTransportFactory()
  • Method Details

    • createListener

      public TransportListener createListener(int port, int maxCountConnections, String encoding) throws IOException
      Create a TCP socket transport listener on the specified port with the given maximum count of connections and encoding.
      Specified by:
      createListener in interface TransportFactory
      Parameters:
      port - the port number to listen on
      maxCountConnections - the maximum number of connections allowed
      encoding - the encoding used for communication
      Returns:
      a TcpSocketTransportListener object
      Throws:
      IOException - if an error occurs during listener creation
    • createConnection

      public TransportConnection createConnection(String ip, int port, String encoding) throws IOException
      Create a TCP socket transport connection to the specified IP address and port with the given encoding.
      Specified by:
      createConnection in interface TransportFactory
      Parameters:
      ip - the IP address to connect to
      port - the port number to connect to
      encoding - the encoding used for communication
      Returns:
      a TcpSocketTransportConnection object
      Throws:
      IOException - if an error occurs during connection creation