Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ef23a8c15385f0e8075e3d20183bc1d2835c6bb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdi.internal.connect;


import java.io.IOException;

import com.sun.jdi.connect.Transport;
import com.sun.jdi.connect.spi.Connection;
import com.sun.jdi.connect.spi.TransportService.ListenKey;

public class SocketTransportImpl implements Transport {
    public static final String TRANSPORT_NAME = "dt_socket"; //$NON-NLS-1$
	public static final int MIN_PORTNR = 0;
	public static final int MAX_PORTNR = 65535;
	
	SocketTransportService service;
    private ListenKey fListenKey;
	
	/**
	 * Constructs new SocketTransportImpl.
	 */	
	public SocketTransportImpl() {
		service = new SocketTransportService();
	}

    /* (non-Javadoc)
     * @see com.sun.jdi.connect.Transport#name()
     */
    public String name() {
        return TRANSPORT_NAME;
    }

    public Connection attach(String hostname, int port, long attachTimeout, long handshakeTimeout) throws IOException {
        return service.attach(hostname, port, attachTimeout, handshakeTimeout);
    }

    public String startListening(int port) throws IOException {
        fListenKey = service.startListening(port+""); //$NON-NLS-1$
        return fListenKey.address();
    }

    public void stopListening() throws IOException {
        service.stopListening(fListenKey);
    }
    
    public Connection accept(long attachTimeout, long handshakeTimeout) throws IOException {
        return service.accept(fListenKey, attachTimeout, handshakeTimeout);
    }

    
}

Back to the top