add websocket state check to read/write functions. add additional error handling to failed sec-websocket-accept checksum