it might be useful to add an example on handling connection error - for example, the port being closed. at least i couldn't figure that out :)