Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.ececs.uc.edu!news.kei.com!news.mathworks.com!nntp.primenet.com!howland.erols.net!EU.net!usenet2.news.uk.psi.net!uknet!usenet1.news.uk.psi.net!uknet!dispatch.news.demon.net!demon!tarrant.microlise.co.uk!news From: andrewg@microlise.co.uk (Andrew Gierth) Newsgroups: comp.unix.programmer,comp.unix.bsd,comp.unix.questions Subject: Re: Connection return value Followup-To: comp.unix.programmer Date: 25 Sep 1996 20:52:57 +0100 Organization: Microlise Engineering Ltd. Lines: 34 Message-ID: <ufsp86l6cm.fsf@zen.microlise.co.uk> References: <32493418.1604@cod.nosc.mil> NNTP-Posting-Host: zen.microlise.co.uk X-NNTP-Posting-Host: microl.demon.co.uk In-reply-to: Grace Huynh's message of Wed, 25 Sep 1996 13:31:04 GMT X-Attribution: AG X-Mayan-Date: Long count = 12.19.3.9.7; tzolkin = 12 Manik; haab = 10 Chen X-Geek: (V3.1) GCS/IT/CC d-(pu) s:+> a- C++++$ UACHV++++$ P--- L E++ W(--) N+++ o? K? w--- O+++ M- V-- PS+ PE Y+(--) PGP- t+@ 5+++ X R@ tv(-) b++ DI? !D G++ e h* !r y Cc: Grace Huynh <gpham@cod.nosc.mil> X-Newsreader: Gnus v5.1 Xref: euryale.cc.adfa.oz.au comp.unix.programmer:43755 comp.unix.bsd:16828 comp.unix.questions:88253 >>>>> "Grace" == Grace Huynh <gpham@cod.nosc.mil> writes: Grace> When I go through the socket programming book, I couldn't find Grace> anything that mention about return a value equal exactly 0. Grace> The book only covers > 0 or <0, but nothing about equal to 0. Grace> So please confirm this with me. Grace> If connect() system call return a value < 0 then connection is not Grace> success. Grace> If connect() system call return a value > 0 then the socket Grace> successully connect Grace> What if connect() return a value == 0? And this is my case. Grace> To me, It's means my connection is success correct? connect() should not return values >0. The expected result is either 0, indicating success, or -1, indicating failure. The best test to use is probably if (connect(sock, &addr, sizeof(addr)) < 0) { ...handle failure... } Hope this helps (There are examples at http://www.auroraonline.com/sock-faq that you might find helpful.) -- Andrew Gierth (andrewg@microlise.co.uk) "Ceterum censeo Microsoftam delendam esse" - Alain Knaff in nanam