Re: httplib again...

Ron Forrester (rjf@aurora.pcg.com)
Mon, 23 Jan 1995 12:38:55 -0700

> There are a thousand things that could have gone wrong there. Since
> you apparently hacked socketmodule.c (how?) it could be a problem in
> your hack, but it could also be a problem in your system's socket
> implementation, or maybe in your site's configuration -- can you reach
> the host mentioned in the test program?

I was able to contact the hose via Mosaic and ftp.

This is pretty NT specific, but all I really did to socketmodule.c is to
change the way makefile worked -- here's what I have now:

---

/* s.makefile(mode) method. Create a new open file object referring to a dupped version of the socket's file descriptor. (The dup() call is necessary so that the open file and socket objects may be closed independent of each other.) The mode argument specifies 'r' or 'w' passed to fdopen(). */

static PyObject * BUILD_FUNC_DEF_2(PySocketSock_makefile,PySocketSockObject *,s, PyObject *,args) { extern int fclose PROTO((FILE *)); char *mode; int fd; FILE *fp; if (!PyArg_Parse(args, "s", &mode)) return NULL; #ifdef NT if ((fd = _open_osfhandle ( s->sock_fd, 0 )) < 0 || (fp = fdopen(fd, mode)) == NULL) #else if ((fd = dup(s->sock_fd)) < 0 || (fp = fdopen(fd, mode)) == NULL) #endif return PySocket_Err(); return PyFile_FromFile(fp, "<socket>", mode, fclose); }

---

Under NT, socket handles are consider OS handles (i.e. the same type returned by kernel calls lile CreateFile()). The function _open_osfhandle() is provided to take an OS handle and create a C file handle from it. The 0 I am passing in is for READ mode, perhaps I need to spend some more time to see what exactly is doing on there.

rjf

-- 
| "I don't like being bluffed -- makes me doubt     |    rjf@aurora.pcg.com |
| my perception of reality..."                      |            71722,3175 |
|                      Chris in the morning on KBHR |                       |
+---------------------------------------------------+-----------------------+