当前位置: 首页>>代码示例>>Java>>正文


Java TransportTimeoutException类代码示例

本文整理汇总了Java中com.sun.jdi.connect.TransportTimeoutException的典型用法代码示例。如果您正苦于以下问题:Java TransportTimeoutException类的具体用法?Java TransportTimeoutException怎么用?Java TransportTimeoutException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransportTimeoutException类属于com.sun.jdi.connect包,在下文中一共展示了TransportTimeoutException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.sun.jdi.connect.TransportTimeoutException; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:AcceptTimeout.java

示例2: accept

import com.sun.jdi.connect.TransportTimeoutException; //导入依赖的package包/类
@Override
public Connection accept(ListenKey listenKey, long attachTimeout, long handshakeTimeout) throws IOException {
	if (attachTimeout > 0) {
		if (attachTimeout > Integer.MAX_VALUE) {
			attachTimeout = Integer.MAX_VALUE; // approx 25 days!
		}
		fServerSocket.setSoTimeout((int) attachTimeout);
	}
	Socket socket;
	try {
		socket = fServerSocket.accept();
	} catch (SocketTimeoutException e) {
		throw new TransportTimeoutException();
	}
	InputStream input = socket.getInputStream();
	OutputStream output = socket.getOutputStream();
	performHandshake(input, output, handshakeTimeout);
	return new SocketConnection(socket, input, output);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:20,代码来源:SocketTransportService.java

示例3: accept

import com.sun.jdi.connect.TransportTimeoutException; //导入依赖的package包/类
/**
 * Accept a connection from a debuggee and handshake with it.
 */
public Connection accept(ListenKey listener, long acceptTimeout, long handshakeTimeout) throws IOException {
    if (acceptTimeout < 0 || handshakeTimeout < 0) {
        throw new IllegalArgumentException("timeout is negative");
    }
    if (!(listener instanceof SocketListenKey)) {
        throw new IllegalArgumentException("Invalid listener");
    }
    ServerSocket ss;

    // obtain the ServerSocket from the listener - if the
    // socket is closed it means the listener is invalid
    synchronized (listener) {
        ss = ((SocketListenKey)listener).socket();
        if (ss.isClosed()) {
           throw new IllegalArgumentException("Invalid listener");
        }
    }

    // from here onwards it's possible that the ServerSocket
    // may be closed by a call to stopListening - that's okay
    // because the ServerSocket methods will throw an
    // IOException indicating the socket is closed.
    //
    // Additionally, it's possible that another thread calls accept
    // with a different accept timeout - that creates a same race
    // condition between setting the timeout and calling accept.
    // As it is such an unlikely scenario (requires both threads
    // to be using the same listener we've chosen to ignore the issue).

    ss.setSoTimeout((int)acceptTimeout);
    Socket s;
    try {
        s = ss.accept();
    } catch (SocketTimeoutException x) {
        throw new TransportTimeoutException("timeout waiting for connection");
    }

    // handshake here
    handshake(s, handshakeTimeout);

    return new SocketConnection(s);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:SocketTransportService.java


注:本文中的com.sun.jdi.connect.TransportTimeoutException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。