Add timeout to socket operations