954,135 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Checking if the socket is valid in C

Hi, does anybody know how check whether the socket (ie file descriptor) is valid in C? I know it is probably possible to do it using either a read or a write command, however, what other ways are there? Thanks.

MIGSoft
Posting Pro in Training
473 posts since Jul 2005
Reputation Points: 10
Solved Threads: 2
 
Hi, does anybody know how check whether the socket (ie file descriptor) is valid in C? I know it is probably possible to do it using either a read or a write command, however, what other ways are there? Thanks.

Depends on the socket that you are using. If you are using the berkely sockets, they have (I think) -1 as the value for the invalid socket. Look up the documentation for this. The Winsock API uses the INVALID_SOCKET value to determine an invalid socket. (Look up the Winsock API Documentation)

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You