danger.app
Class SocketRegistrar

java.lang.Object
  |
  +--danger.app.SocketRegistrar

public final class SocketRegistrar
extends java.lang.Object

Static methods and fields to implement socket-like IPC at the Java level. This is defined as a separate class from Registrar because it's a big enough hunk of code and with separate-enough functionality that it deserves not to be lost in the shuffle.


Method Summary
static IPCServerSocket makeServerSocket(java.lang.String name)
          Create and return a server socket with the given name.
static IPCSocket makeSocket(java.lang.String name)
          Convenience method to call makeSocket(java.lang.String, int) with no timeout.
static IPCSocket makeSocket(java.lang.String name, int timeout)
          Open a connection to the server socket with the given name and return the socket that can talk on that connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeServerSocket

public static IPCServerSocket makeServerSocket(java.lang.String name)
Create and return a server socket with the given name. This will throw if a socket with the given name already exists.
Parameters:
name - non-null; the name of the socket
Returns:
non-null; a socket server with the given name

makeSocket

public static IPCSocket makeSocket(java.lang.String name,
                                   int timeout)
                            throws java.io.IOException
Open a connection to the server socket with the given name and return the socket that can talk on that connection. Wait up to the given timeout for the connection to be made or give up and throw InterruptedIOException. If the timeout is given as 0, then wait indefinitely.
Parameters:
name - non-null; the name of the server socket
timeout - >= 0; the timeout in milliseconds
Returns:
non-null; a newly-connected socket
Throws:
java.io.IOException - thrown if there's trouble

makeSocket

public static IPCSocket makeSocket(java.lang.String name)
                            throws java.io.IOException
Convenience method to call makeSocket(java.lang.String, int) with no timeout.
Parameters:
name - non-null; the name of the server socket
Returns:
non-null; a newly-connected socket
Throws:
java.io.IOException - thrown if there's trouble


Danger Confidential. Copyright © 2000-2003, Danger Inc.