This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

getsockopt() SO_ERROR optval mapping


This patch maps getsockopt() SO_ERROR optval's from their Winsock versions to
their corresponding errno versions.  This prevents strerror(optval) from
generating cryptic messages like:

    error 10061

instead of:

    Connection refused

Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com
Index: net.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/net.cc,v
retrieving revision 1.43
diff -u -p -r1.43 net.cc
--- net.cc	2001/03/20 19:50:28	1.43
+++ net.cc	2001/04/02 18:36:43
@@ -584,10 +584,22 @@ cygwin_getsockopt (int fd,
 	case SO_OOBINLINE:
 	  name="SO_OOBINLINE";
 	  break;
+	case SO_ERROR:
+	  name="SO_ERROR";
+	  break;
 	}
 
       res = getsockopt (h->get_socket (), level, optname,
 				       (char *) optval, (int *) optlen);
+
+      /* For the SO_ERROR case, convert optval from Winsock to errno errors. */
+      if (optname == SO_ERROR)
+	{
+	  int *p = (int *) optval;
+	  for (int i = 0; errmap[i].w != 0; ++i)
+	    if (*p == errmap[i].w)
+	      *p = errmap[i].e;
+	}
 
       if (res)
 	set_winsock_errno ();
Mon Apr  2 14:58:53 2001  Jason Tishler <jt@dothill.com>

	* net.cc (cygwin_getsockopt): Add SO_ERROR support -- specifically,
	the mapping of Winsock optval's to their corresponding errno versions.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]