FileDocCategorySizeDatePackage
TCPOBEXNotifier.javaAPI DocphoneME MR2 API (J2ME)4025Wed May 02 18:00:30 BST 2007com.sun.midp.io.j2me.tcpobex

TCPOBEXNotifier

public class TCPOBEXNotifier extends Object implements com.sun.kvem.jsr082.obex.ObexTransportNotifier
Provides TCP OBEX stream notifier to shared obex implementation.

Fields Summary
private com.sun.midp.io.j2me.serversocket.Socket
serverSocket
TCP server socket that accepts connections to this notifier.
private int
port
The sever socket port this notifier accepts connections on.
private boolean
isClosed
Indicates if this notifier is closed.
Constructors Summary
protected TCPOBEXNotifier(com.sun.midp.security.SecurityToken securityToken, int port)
Constracts TCPOBEXNotifier instance.

param
securityToken The security token.
param
port The host's port to listen on.
throws
IOException if any error occures.


                               
        
                                                         
        Protocol sp = new Protocol();

        if (port == 0) {
            serverSocket = (Socket) sp.openPrim(securityToken, "//");
        } else {
            serverSocket = (Socket) sp.openPrim(securityToken, "//:" + port);
        }
        
        this.port = serverSocket.getLocalPort();
    
Methods Summary
public com.sun.kvem.jsr082.obex.ObexTransportacceptAndOpen()
Accepts new tcpobex transport connection.

return
TCPOBEXConnection.
throws
IOException if thrown by server socket operations or this notifier is closed

        StreamConnection conn = serverSocket.acceptAndOpen();
        Object[] param = new Object[3];
        
        param[0] = conn.openInputStream();
        param[1] = conn.openOutputStream();
        param[2] = null; // close the connection now
        conn.close();
        
        return createTransportConnection(param);
    
public synchronized voidclose()
Closes the underlaying tcp/socket notifier.

throws
IOException if thrown by server socket methods

        if (!isClosed) {
            isClosed = true;
            serverSocket.close();
        }
    
protected TCPOBEXConnectioncreateTransportConnection(java.lang.Object[] sockData)
Creates TCP OBEX transport connection.

param
sockData An array of the streams.
return
TCPOBEXConnection.
throws
IOException

        return new TCPOBEXConnection(sockData);
    
public javax.microedition.io.ConnectiongetUnderlyingConnection()
Gets underlying connection.

return
Always returns null.

        return null;