sandeep
sandeep

Reputation: 115

How can I check Recv or send point of the socket is shutdown

In my server prosgram, I have shutdown the recv end of socket to refuse the incoming data.

Sometimes later in the code i wish to check if my recv end is closed or not. How can i check this? I didnt find anything interesting in getsockopt.

Thanks, Sandeep

Upvotes: 0

Views: 463

Answers (2)

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215259

Probably by storing a flag alongside wherever you store the socket fd. Surely that will be more efficient than making additional syscalls...

Upvotes: 1

Juarrow
Juarrow

Reputation: 2384

How about getsockopt(/*SO_CONNECT_TIME*/)?... it will return SOCKET_ERROR of the socket isn´t connected...

I suggest You to use closesocket() on the socket to ensure it has been really closed and not only shut down.

Upvotes: 0

Related Questions