Class SocketConnection

java.lang.Object
com.codename1.io.SocketConnection

public abstract class SocketConnection extends Object
Callback for establishment of a socket connection. Notice this callback is always invoked on a new separate thread to allow uninterrupted IO.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    SocketConnection(int connectTimeout)
    Creates a socket connection, setting the connect timeout.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    connectionError(int errorCode, String message)
    Invoked in case of an error in the socket connection, this method is invoked off the EDT
    abstract void
    Invoked when a socket connection is established, this method is invoked off the EDT
    int
    Gets the connect timeout.
    boolean
    Returns true if this connection is currently active
    void
    setConnectTimeout(int connectTimeout)
    Sets the connect timeout.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • SocketConnection

      public SocketConnection()
    • SocketConnection

      public SocketConnection(int connectTimeout)

      Creates a socket connection, setting the connect timeout. Timeout of 0 is infinite.

      Parameters
      • connectTimeout: The connect timeout. 0 for infinite.
      Since

      7.0

  • Method Details

    • connectionError

      public abstract void connectionError(int errorCode, String message)

      Invoked in case of an error in the socket connection, this method is invoked off the EDT

      Parameters
      • errorCode: the error code

      • message: error message if applicable

    • connectionEstablished

      public abstract void connectionEstablished(InputStream is, OutputStream os)

      Invoked when a socket connection is established, this method is invoked off the EDT

      Parameters
      • is: input stream for the socket

      • os: output stream for the socket

    • isConnected

      public boolean isConnected()

      Returns true if this connection is currently active

      Returns

      true if connected

    • getConnectTimeout

      public int getConnectTimeout()

      Gets the connect timeout.

      Returns

      The connect timeout. 0 for infinite.

    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)

      Sets the connect timeout.

      Parameters
      • connectTimeout: The connect timeout. 0 for infinite timeout.
      Since

      7.0