From owner-freebsd-questions Wed Aug 21 12:52: 9 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 57C0F37B400 for ; Wed, 21 Aug 2002 12:52:04 -0700 (PDT) Received: from janeway.vonbek.dhs.org (bgm-24-24-79-198.stny.rr.com [24.24.79.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 91FF543E97 for ; Wed, 21 Aug 2002 12:52:03 -0700 (PDT) (envelope-from syborg@stny.rr.com) Received: by janeway.vonbek.dhs.org (Postfix, from userid 507) id CE4C34FA51; Wed, 21 Aug 2002 15:49:34 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by janeway.vonbek.dhs.org (Postfix) with ESMTP id C697A4A0D; Wed, 21 Aug 2002 15:49:34 -0400 (EDT) Date: Wed, 21 Aug 2002 15:49:34 -0400 (EDT) From: John Bleichert X-X-Sender: syborg@janeway.vonbek.dhs.org Reply-To: John Bleichert To: Gianmarco Giovannelli Cc: questions@FreeBSD.ORG Subject: Re: Porting from win32 to UNIX: Sockets In-Reply-To: <5.1.1.6.2.20020821204121.02ad7008@194.184.65.4> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 21 Aug 2002, Gianmarco Giovannelli wrote: > Date: Wed, 21 Aug 2002 20:44:27 +0200 > From: Gianmarco Giovannelli > To: questions@FreeBSD.ORG > Subject: Porting from win32 to UNIX: Sockets > > Hi a friend of mine involved in a porting project. > He has asking me something about socket and more I am not able to answer :-) > > Thanks for your attention... > > --- begin --- > > [...] > that are familiar with "low-level-TCP/IP" coding. > plz help > > following problem: > I don't know how to get an errorcode in case of socket-operation failed > (send/recv) > in windows it goes like this > > e.g > res = send(....); > if (res==SOCKET_ERROR) > { > err = WSAGetLastError(); > if (err==....) ...; > } > > but how to do this in linux/UNIX/BSD ? > what's the equivalent of WSAGetLastError ? > > furthermore I need to know the errorcodes of > "wouldblock" and "connreset" > > > --- end --- > > Best Regards, > Gianmarco Giovannelli , "Unix expert since yesterday" Errors are stored in the errno(3) variable. To read this, try something like: if ((br= read(s,buf,n-bcount)) > 0) { // do something } else { printf("error returned: %s\n", strerror(errno)); } check out the errno(3) and strerror(3) man pages. JB /* * John Bleichert * syborg@stny.rr.com * http://vonbek.dhs.org/latest.jpg */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message