Add timeout for socket operations