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!!
boostaAsked:
Who is Participating?
 
rbrCommented:
if (connect(sockfd,pserv_addr,addrlen ) < 0)
      printf ("Error: %s",strerror (errno));

0
 
ahoffmannCommented:
or simply:
perror("prefix to message" );
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.