Date: Wed, 21 Aug 2002 15:49:34 -0400 (EDT) From: John Bleichert <syborg@stny.rr.com> To: Gianmarco Giovannelli <gmarco@giovannelli.it> Cc: questions@FreeBSD.ORG Subject: Re: Porting from win32 to UNIX: Sockets Message-ID: <Pine.LNX.4.44.0208211547160.17257-100000@janeway.vonbek.dhs.org> In-Reply-To: <5.1.1.6.2.20020821204121.02ad7008@194.184.65.4>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 21 Aug 2002, Gianmarco Giovannelli wrote: > Date: Wed, 21 Aug 2002 20:44:27 +0200 > From: Gianmarco Giovannelli <gmarco@giovannelli.it> > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.44.0208211547160.17257-100000>