how to block a socket indefinitely
When a socket is created, by default it is a blocking socket. Under blocking mode socket I/O operations, connect and accept operations all block until the operation in question is completed.
I want to receive data periodically from a client. That is, the first time I receive data the socket is blocked in the accept function but the next time is not blocked anymore and I want that it waits for the next incoming data.
I used the ioctlsocket function after the accept function this way:
but I get this error message at the ioctlsocket function: 10093, and I read that is because the WSAStartup() was wrong but it isn't so.
AcceptSocket = SOCKET_ERROR;
while (AcceptSocket == SOCKET_ERROR)
AcceptSocket = accept(socketInTCP, NULL, NULL);
ioctlsocket=(socketInTCP, FIONBIO, &imode);
Can you help me
thank you very much.