Make net read and write functions cancellable, add new socket state check functions.