1

I want to ask about something when I want to set timeout with specific socket i call this function

void Server::setReceiveTimeout(unsigned int timeout, SOCKET clientSocket)
{
    if (setsockopt(clientSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)))
        cout << "could not set socket option " << endl;
}

and it is working well

now my question

if i set the clientsocket to a specific timeout ..how could i return clientsocket back so there is no timeout?

for example settimeout(3000); recv

then after recv I want to return it back to the state where no time out How ?

your help will be greatly appreciated :)

Rehab Reda
  • 193
  • 7
  • 16

1 Answers1

0

Set it to zero. "If the timeout is set to zero (the default), then the operation will never timeout."

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Thank you EJP :) but the problem is that I am doing something like this Send(); setTimeOut(3000); recv(); setTimeOut(0); it is not working why ?? do i have to set the timeout before sending or receiving ? – Rehab Reda Apr 07 '14 at 05:30
  • I don't understand this question. – user207421 Apr 07 '14 at 08:19