in reply to IO::Socket not connecting
It is clear that your code has no problem, other than the minor issue dave_the_m pointed out, which was unrelated. The only answer is that the other party is not listening.