FileDocCategorySizeDatePackage
SocketTransport.javaAPI DocphoneME MR2 API (J2ME)4220Wed May 02 17:59:48 BST 2007com.sun.cldchi.tools.memoryprofiler.jdwp

SocketTransport

public class SocketTransport extends Transport
This class represents a socket transport for JDWP. Actually is used as proxy that communicates with SocketTransportImpl that works in another thread and performs all the job for communicating with VM being debugged via JDWP.
see
jdwp.SocketTransportImpl
see
jdwp.Transport

Fields Summary
private SocketTransportImpl
socketImpl
A SocketTransportImpl object that performs all the communications.
Constructors Summary
Methods Summary
public voidHandshake()
Initialtes handshake procedure. This procedure is performed immediately after establishing TCP/IP connection and consist on sending and receiving "JDWP-Handshake" string.

        socketImpl.startHandShake(new String("JDWP-Handshake").getBytes().length);
        super.Handshake();
    
public voidattachToServer(java.lang.String ServerName, int PortNumber)
Connects to the specified port number on the named host. For this task this mehtod initializes a SocketTransportImpl object that works in another thread and manipulates it.

param
ServerName a host where VM being debugged is running
param
PortNumber a TCP/IP port number to communicate with VM being debugged

        socketImpl = new SocketTransportImpl();
        socketImpl.initAsClient(ServerName, PortNumber, Replies);
        synchronized(socketImpl){
            socketImpl.start();
            try{
                socketImpl.wait();
            }catch(InterruptedException e){
            }
        }
        if(!socketImpl.isStarted()){
            throw new IOException("Connection is not established");
        }
        //System.out.println("Attached");
    
public intavailable()
Returns a number of bytes that are available for reading.

return
a number of bytes that are available for reading

        return socketImpl.availableInPrivateBuffer();
    
public voiddone()
Closes socket and streams.

        if(socketImpl != null){
            socketImpl.done();
            socketImpl = null;
        }
    
public intread()
Reads the next byte from the buffer. This byte is already read from the socket and stored in some buffer.

return
a next byte from the buffer
see
jdwp.SocketTransportImpl#readNextFromPrivateBuffer()

        return socketImpl.readNextFromPrivateBuffer();
    
public voidreceive()
Stores the received JDWP replies to the Replies vector.

see
jdwp.Transport#Replies

        socketImpl.receive();
    
public voidwrite(int b)
Writes the specified byte to the socket.

        socketImpl.write(b);