Problem: generated API is not handling timeouts or interrupts

Solution: return -1/NULL for methods when they interrupt while
reading from sockets.