org.jgroups.util

## Interface SocketFactory

- All Known Implementing Classes:
    DefaultSocketFactory

      public interface SocketFactory

  Factory to create various types of sockets. For socket creation, a service name can be passed as argument: an implementation could look up a service description (e.g. port) and create the socket, ignoring the passed port and possibly also the bind address.

  Ephemeral ports can be created by passing 0 as port, or (if the port is ignored), an implementation could pass in a special service name (e.g. "EPHEMERAL"), this is implementation dependent.

  The socket creation methods have the same parameter lists as the socket constructors, e.g. `createServerSocket(String, int, int)` is the same as `java.net.ServerSocket(int,int)`.
  Author:
    Bela Ban

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(java.net.DatagramSocket sock)`
    `void` | `close(java.net.ServerSocket sock)`
    `void` | `close(java.net.Socket sock)`
    `java.net.DatagramSocket` | `createDatagramSocket(java.lang.String service_name)`
    `java.net.DatagramSocket` | `createDatagramSocket(java.lang.String service_name, int port)`
    `java.net.DatagramSocket` | `createDatagramSocket(java.lang.String service_name, int port, java.net.InetAddress laddr)`
    `java.net.DatagramSocket` | `createDatagramSocket(java.lang.String service_name, java.net.SocketAddress bindaddr)`
    `java.net.MulticastSocket` | `createMulticastSocket(java.lang.String service_name)`
    `java.net.MulticastSocket` | `createMulticastSocket(java.lang.String service_name, int port)`
    `java.net.MulticastSocket` | `createMulticastSocket(java.lang.String service_name, java.net.SocketAddress bindaddr)`
    `java.net.ServerSocket` | `createServerSocket(java.lang.String service_name)`
    `java.net.ServerSocket` | `createServerSocket(java.lang.String service_name, int port)`
    `java.net.ServerSocket` | `createServerSocket(java.lang.String service_name, int port, int backlog)`
    `java.net.ServerSocket` | `createServerSocket(java.lang.String service_name, int port, int backlog, java.net.InetAddress bindAddr)`
    `java.net.Socket` | `createSocket(java.lang.String service_name)`
    `java.net.Socket` | `createSocket(java.lang.String service_name, java.net.InetAddress address, int port)`
    `java.net.Socket` | `createSocket(java.lang.String service_name, java.net.InetAddress address, int port, java.net.InetAddress localAddr, int localPort)`
    `java.net.Socket` | `createSocket(java.lang.String service_name, java.lang.String host, int port)`
    `java.net.Socket` | `createSocket(java.lang.String service_name, java.lang.String host, int port, java.net.InetAddress localAddr, int localPort)`
    `java.util.Map<java.lang.Object,java.lang.String>` | `getSockets()` Returns all open sockets.

- - ### Method Detail

    - #### createSocket

          java.net.Socket createSocket(java.lang.String service_name)
                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createSocket

          java.net.Socket createSocket(java.lang.String service_name,
                                     java.lang.String host,
                                     int port)
                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createSocket

          java.net.Socket createSocket(java.lang.String service_name,
                                     java.net.InetAddress address,
                                     int port)
                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createSocket

          java.net.Socket createSocket(java.lang.String service_name,
                                     java.lang.String host,
                                     int port,
                                     java.net.InetAddress localAddr,
                                     int localPort)
                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createSocket

          java.net.Socket createSocket(java.lang.String service_name,
                                     java.net.InetAddress address,
                                     int port,
                                     java.net.InetAddress localAddr,
                                     int localPort)
                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createServerSocket

          java.net.ServerSocket createServerSocket(java.lang.String service_name)
                                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createServerSocket

          java.net.ServerSocket createServerSocket(java.lang.String service_name,
                                                 int port)
                                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createServerSocket

          java.net.ServerSocket createServerSocket(java.lang.String service_name,
                                                 int port,
                                                 int backlog)
                                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createServerSocket

          java.net.ServerSocket createServerSocket(java.lang.String service_name,
                                                 int port,
                                                 int backlog,
                                                 java.net.InetAddress bindAddr)
                                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createDatagramSocket

          java.net.DatagramSocket createDatagramSocket(java.lang.String service_name)
                                                       throws java.net.SocketException

      Throws:
        `java.net.SocketException`

    - #### createDatagramSocket

          java.net.DatagramSocket createDatagramSocket(java.lang.String service_name,
                                                     java.net.SocketAddress bindaddr)
                                                       throws java.net.SocketException

      Throws:
        `java.net.SocketException`

    - #### createDatagramSocket

          java.net.DatagramSocket createDatagramSocket(java.lang.String service_name,
                                                     int port)
                                                       throws java.net.SocketException

      Throws:
        `java.net.SocketException`

    - #### createDatagramSocket

          java.net.DatagramSocket createDatagramSocket(java.lang.String service_name,
                                                     int port,
                                                     java.net.InetAddress laddr)
                                                       throws java.net.SocketException

      Throws:
        `java.net.SocketException`

    - #### createMulticastSocket

          java.net.MulticastSocket createMulticastSocket(java.lang.String service_name)
                                                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createMulticastSocket

          java.net.MulticastSocket createMulticastSocket(java.lang.String service_name,
                                                       int port)
                                                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### createMulticastSocket

          java.net.MulticastSocket createMulticastSocket(java.lang.String service_name,
                                                       java.net.SocketAddress bindaddr)
                                                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### close

          void close(java.net.Socket sock)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### close

          void close(java.net.ServerSocket sock)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### close

          void close(java.net.DatagramSocket sock)

    - #### getSockets

          java.util.Map<java.lang.Object,java.lang.String> getSockets()

      Returns all open sockets. This method can be used to list or close all open sockets.
      Returns:
        A map of open sockets; keys are Sockets, ServerSockets, DatagramSockets or MulticastSockets, values are the service names.

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.