[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

C under UNIX

In C, a the function connect() returns a non-zero integer on success and a negative integer on error, placed inside errno! I want to know how to view the error returned as a string using the system function strerror() or its equivalent!!
0
boosta
Asked:
boosta
1 Solution
 
rbrCommented:
if (connect(sockfd,pserv_addr,addrlen ) < 0)
      printf ("Error: %s",strerror (errno));

0
 
ahoffmannCommented:
or simply:
perror("prefix to message" );
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now