*BSD News Article 79158


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!nntp.coast.net!zombie.ncsc.mil!newsgate.duke.edu!news.mathworks.com!uunet!in2.uu.net!news2.interlog.com!empress.empress.com!fireopal.empress.com!gman
From: gman@fireopal.empress.com (Gordon Man)
Newsgroups: comp.unix.programmer,comp.unix.bsd,comp.unix.questions
Subject: Re: Connection return value
Followup-To: comp.unix.programmer,comp.unix.bsd,comp.unix.questions
Date: 25 Sep 1996 19:40:17 GMT
Organization: Empress Software Inc.
Lines: 47
Message-ID: <52c1r1$ntp@empress.empress.com>
References: <32493418.1604@cod.nosc.mil>
NNTP-Posting-Host: fireopal.empress.com
X-Newsreader: TIN [version 1.2 PL2]
Xref: euryale.cc.adfa.oz.au comp.unix.programmer:43753 comp.unix.bsd:16827 comp.unix.questions:88251

Grace Huynh (gpham@cod.nosc.mil) wrote:
: When I go through the socket programming book,  I couldn't find anything
: that mention
: about return a value equal exactly 0.  The book only covers > 0 or <0,
: but nothing about equal to 0.  So please confirm this with me.

: If connect() system call return a value < 0 then connection is not
: success.
: If connect() system call return a value > 0 then the socket successully
: connect

: What if connect() return a value == 0?  And this is my case.  To me,
: It's means my connection is success correct?

I don't know anything about your programming book which could be wrong.
I don't think there is a case that connect() returns > 0.
In fact, there is only 2 cases: 0 and -1.

The linux man page of connect:

       If the connection or binding succeeds, zero  is  returned.
       On  error, -1 is returned, and errno is set appropriately.

Solaris man page of connect:

     If the connection or binding succeeds, 0 is returned.   Oth-
     erwise, -1 is returned and sets errno to indicate the error.

AIX man page of connect:

Upon successful completion, the connect subroutine returns a value
of 0.

If the connect subroutine is unsuccessful, the system handler performs
the following functions:

*       Returns a value of -1 to the calling program.

*       Moves an error code, indicating the specific error, into the
errno global variable.



--
Gordon Man
gman@empress.com