KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdi > internal > connect > SocketTransportImpl


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdi.internal.connect;
12
13
14 import java.io.IOException JavaDoc;
15
16 import com.sun.jdi.connect.Transport;
17 import com.sun.jdi.connect.spi.Connection;
18 import com.sun.jdi.connect.spi.TransportService.ListenKey;
19
20 public class SocketTransportImpl implements Transport {
21     public static final String JavaDoc TRANSPORT_NAME = "dt_socket"; //$NON-NLS-1$
22
public static final int MIN_PORTNR = 0;
23     public static final int MAX_PORTNR = 65535;
24     
25     SocketTransportService service;
26     private ListenKey fListenKey;
27     
28     /**
29      * Constructs new SocketTransportImpl.
30      */

31     public SocketTransportImpl() {
32         service = new SocketTransportService();
33     }
34
35     /* (non-Javadoc)
36      * @see com.sun.jdi.connect.Transport#name()
37      */

38     public String JavaDoc name() {
39         return TRANSPORT_NAME;
40     }
41
42     public Connection attach(String JavaDoc hostname, int port, long attachTimeout, long handshakeTimeout) throws IOException JavaDoc {
43         return service.attach(hostname, port, attachTimeout, handshakeTimeout);
44     }
45
46     public String JavaDoc startListening(int port) throws IOException JavaDoc {
47         fListenKey = service.startListening(port+""); //$NON-NLS-1$
48
return fListenKey.address();
49     }
50
51     public void stopListening() throws IOException JavaDoc {
52         service.stopListening(fListenKey);
53     }
54     
55     public Connection accept(long attachTimeout, long handshakeTimeout) throws IOException JavaDoc {
56         return service.accept(fListenKey, attachTimeout, handshakeTimeout);
57     }
58
59     
60 }
61
Popular Tags