SwiftSocket
SwiftSocket copied to clipboard
Next read request on accepted client doesn't returns
I'm writing a server module using TCPServer api of SwiftSocket. TCPServer accept a client and then in a infinite loop I want to read the request data from the client and respond to the same client with some response till it ask for breaking the session. Below is the snippet of server IO:
while true { if weakOperation.isCancelled { break } if let bytes = self.read() { let respPacket: [UInt8] = self.ioManager.process(command: bytes) self.write(respPacket) } // sleep for 10 ms //usleep(10 * 1000) print("waiting for data to get ...") }
I'm able to read from client and write to client but next read request never returns. Am I missing anything here ?