Game console idea

I love being able to install games to by Xbox 360. It makes playing much quieter & stuff seems to load faster. Unfortunately, like PC games I’ve played in the past, playing a game from the hard drive requires the disc to be in the player. Makes sense, as it proves that I didn’t copy it from my buddy & pass it around. Here’s the thing…. it sucks! I’m no more lazy than the next person, but come on! I mean, I can turn the console on & off with the wireless remote. I change the turner on my TV with my remote & I’m off & playing .. as long as the game is in the console. So here’s what we do: I usually keep my games close by my console anyway (for easy access - cuz they need to be in to play) so why not install some kind of RFID or wireless thing-a-ma-bob that is part of the game case. The console can just check if it’s in range - and preseto - I don’t have to get off my lazy butt to play!

Proper timeout handling with Apache HttpClient

I’ve seen some really bad things happen when developers don’t code in proper timeout handling. Occasionally I’ve been asked what the best way to handle timeouts is - so I thought I’d share my take on it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
MultiThreadedHttpConnectionManager connectionManager =  new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = connectionManager.getParams();

params.setConnectionTimeout(connectiontimeout); //set connection timeout (how long it takes to connect to remote host)
params.setSoTimeout(sotimeout); //set socket timeout (how long it takes to retrieve data from remote host)

HttpMethodBase baseMethod = null;

try {
HttpClient httpClient = new HttpClient(connectionManager);
httpClient.getParams().setParameter("http.connection-manager.timeout", poolTimeout); //set timeout on how long we'll wait for a connection from the pool

baseMethod = new GetMethod(...);
int statusCode = httpClient.executeMethod(...);

...
}
catch (ConnectTimeoutException cte ){
//Took too long to connect to remote host
}
catch (SocketTimeoutException ste){
//Remote host didn't respond in time
}
catch (Exception se){
//Some other error occurred
}
finally {
if (baseMethod != null)
baseMethod.releaseConnection();
}