【初心者】Java質問・相談スレッド94【大歓迎】
■ このスレッドは過去ログ倉庫に格納されています
0087デフォルトの名無しさん
2006/11/23(木) 12:49:30synchronized( this ){
SocketAddress socketAddress = null;
Socket socket = null;
try {
socket = new Socket();
socket.setKeepAlive(true);
byte[] ip = InetAddress.getByName(this.serverAddress).getAddress();
InetAddress addr = InetAddress.getByAddress(this.serverAddress, ip);
socketAddress = new InetSocketAddress(addr, this.port);
SocketAddress bindAddress = new InetSocketAddress(this.bindip, socket.getPort());
socket.bind(bindAddress);
socket.connect(socketAddress, this.timeout);
socket.close();
socket = null;
} catch (Exception e) {
// 注 : UnknownHostExceptionとか複数の例外もすべて同様
socket.close();
socket = null;
}
}
}
■ このスレッドは過去ログ倉庫に格納されています