Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9252
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | markspace <-@.> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Setting TCP parameters for Socket? |
| Date | Thu, 27 Oct 2011 10:10:34 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 44 |
| Message-ID | <j8c3ad$m2s$1@dont-email.me> (permalink) |
| References | <j8c20r$cmp$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 27 Oct 2011 17:10:37 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="22620"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19byylJ1J4nHbwvBcRU+ntu79JDITl0lf0=" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 |
| In-Reply-To | <j8c20r$cmp$1@dont-email.me> |
| Cancel-Lock | sha1:7NOoxn3y2fmu2Ab7Pa9Y6HhIJIM= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9252 |
Show key headers only | View raw
To partially answer my own question here, it appears that the initial
connection in the Socket constructor is sensitive to Thread.interrupt().
This strikes me as a somewhat hokey solution however. I'm still
hoping for something better.
private static void test2( String hostname, int port ) {
Thread t = new Thread( new ConnectTask( hostname, port ) );
try {
Thread.sleep( 1000 );
} catch(InterruptedException ex) {}
t.interrupt();
while( t.isAlive() ) {
try {
t.join();
} catch (InterruptedException ex ) {}
}
System.out.println("Thread finished. " + t );
}
private static class ConnectTask implements Runnable {
private final String hostname;
private final int port;
public ConnectTask(String hostname, int port) {
this.hostname = hostname;
this.port = port;
}
@Override
public void run() {
try {
Socket sock = new Socket( hostname, port );
System.out.println("created: "+sock);
} catch (IOException ex) {
System.err.println(ex);
throw new RuntimeException(ex);
}
}
}
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Setting TCP parameters for Socket? markspace <-@.> - 2011-10-27 09:48 -0700
Re: Setting TCP parameters for Socket? markspace <-@.> - 2011-10-27 10:10 -0700
Re: Setting TCP parameters for Socket? markspace <-@.> - 2011-10-27 11:16 -0700
Re: Setting TCP parameters for Socket? Steven Simpson <ss@domain.invalid> - 2011-10-27 20:41 +0100
Re: Setting TCP parameters for Socket? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-10-27 23:35 +0200
Re: Setting TCP parameters for Socket? markspace <-@.> - 2011-10-27 15:40 -0700
csiph-web