01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdi.internal.connect;
11:
12: import java.io.IOException;
13:
14: import com.sun.jdi.connect.Transport;
15: import com.sun.jdi.connect.spi.Connection;
16: import com.sun.jdi.connect.spi.TransportService.ListenKey;
17:
18: public class SocketTransportImpl implements Transport {
19: public static final String TRANSPORT_NAME = "dt_socket"; //$NON-NLS-1$
20: public static final int MIN_PORTNR = 0;
21: public static final int MAX_PORTNR = 65535;
22:
23: SocketTransportService service;
24: private ListenKey fListenKey;
25:
26: /**
27: * Constructs new SocketTransportImpl.
28: */
29: public SocketTransportImpl() {
30: service = new SocketTransportService();
31: }
32:
33: /* (non-Javadoc)
34: * @see com.sun.jdi.connect.Transport#name()
35: */
36: public String name() {
37: return TRANSPORT_NAME;
38: }
39:
40: public Connection attach(String hostname, int port,
41: long attachTimeout, long handshakeTimeout)
42: throws IOException {
43: return service.attach(hostname, port, attachTimeout,
44: handshakeTimeout);
45: }
46:
47: public String startListening(int port) throws IOException {
48: fListenKey = service.startListening(port + ""); //$NON-NLS-1$
49: return fListenKey.address();
50: }
51:
52: public void stopListening() throws IOException {
53: service.stopListening(fListenKey);
54: }
55:
56: public Connection accept(long attachTimeout, long handshakeTimeout)
57: throws IOException {
58: return service.accept(fListenKey, attachTimeout,
59: handshakeTimeout);
60: }
61:
62: }
|