Class Socket

java.lang.Object
com.codename1.io.Socket

public final class Socket extends Object
Class implementing the socket API
  • Method Details

    • isSupported

      public static boolean isSupported()

      Returns true if sockets are supported in this port, false otherwise

      Returns

      true if sockets are supported in this port, false otherwise

    • isServerSocketSupported

      public static boolean isServerSocketSupported()

      Returns true if server sockets are supported in this port, if this method returns false invocations of listen will always fail

      Returns

      true if server sockets are supported in this port, false otherwise

      Deprecated
    • connect

      public static void connect(String host, int port, SocketConnection sc)

      Connect to a remote host

      Parameters
      • host: the host

      • port: the connection port

      • sc: callback for when the connection is established or fails

    • connectWithClose

      public static com.codename1.io.Socket.Close connectWithClose(String host, int port, SocketConnection sc)

      Connect to a remote host

      Parameters
      • host: the host

      • port: the connection port

      • sc: callback for when the connection is established or fails

    • listen

      public static Socket.StopListening listen(int port, Class scClass)

      Listen to incoming connections on port

      Parameters
      • port: the device port

      • scClass: @param scClass class of callback for when the connection is established or fails, this class will be instantiated for every incoming connection and must have a public no argument constructor.

      Returns

      StopListening instance that allows the the caller to stop listening on a server socket

      Deprecated
    • getHostOrIP

      public static String getHostOrIP()

      Returns the hostname or ip address of the device if available/applicable

      Returns

      the hostname or ip address of the device if available/applicable