Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2e4855

Browse files
committed
It appears that inet_aton() doesn't really exist except in libresolv;
the proper function to call is inet_addr(). Since we already had code to do that (for MS-Windows), this simplifies things a lot!
1 parent a41c691 commit a2e4855

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

Modules/socketmodule.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,26 +1807,10 @@ binary format used in low-level network functions.";
18071807
static PyObject*
18081808
BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
18091809
{
1810-
#ifndef MS_WINDOWS
1811-
char *ip_addr;
1812-
struct in_addr packed_addr;
1813-
int err;
1814-
1815-
if (!PyArg_Parse(args, "s", &ip_addr)) {
1816-
return NULL;
1817-
}
1818-
1819-
err = inet_aton(ip_addr, &packed_addr);
1820-
1821-
if (err == 0) { /* invalid address */
1822-
PyErr_SetString(PySocket_Error,
1823-
"illegal IP address string passed to inet_aton");
1824-
return NULL;
1825-
}
1810+
#ifndef INADDR_NONE
1811+
#define INADDR_NONE (-1)
1812+
#endif
18261813

1827-
return PyString_FromStringAndSize((char *) &packed_addr,
1828-
sizeof(packed_addr));
1829-
#else /* MS_WINDOWS */
18301814
/* Have to use inet_addr() instead */
18311815
char *ip_addr;
18321816
long packed_addr;
@@ -1845,7 +1829,6 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
18451829

18461830
return PyString_FromStringAndSize((char *) &packed_addr,
18471831
sizeof(packed_addr));
1848-
#endif /* MS_WINDOWS */
18491832
}
18501833

18511834
static char inet_ntoa_doc[] =

0 commit comments

Comments
 (0)