in reply to Net::telnet check for incoming traffic
I think that the select system call is ideal for your problem
select RBITS,WBITS,EBITS,TIMEOUT