The best way is to use the select system call (note there are two different select functions in Perl). It's a bit easier to use it via the IO::Select module. Something like this would work:
if (IO::Select->new(SOCKETHANDLE)->can_read($timeout)) {
do the socket read as normal
} else {
you timed out
}