[Patches] [ python-Patches-908631 ] WinSock 2 support on Win32 w/ MSVC++ 6 (fix #860134)

SourceForge.net noreply at sourceforge.net
Sat Sep 18 18:18:24 CEST 2004


Patches item #908631, was opened at 2004-03-03 00:16
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=908631&group_id=5470

Category: Modules
Group: Python 2.3
>Status: Closed
>Resolution: Out of Date
Priority: 6
Submitted By: Jeff Connelly aka shellreef (jeffconnelly)
Assigned to: Nobody/Anonymous (nobody)
Summary: WinSock 2 support on Win32 w/ MSVC++ 6 (fix #860134)

Initial Comment:
WinSock 2 isn't supported on 2.3. The capability is 
there, but the Microsoft C++ version is incorrectly 
specified to the preprocessor, VC++ 6 (the version used 
to build the official Python Win32 executable) misses the 
#if's and links to wsock32.lib, instead. This results in the 
programmer only being able to use WinSock 1, instead of 
WinSock 2's useful functions.

On modern Win32's, WinSock 2 is prevalent, so the 
switch shouldn't cause too much trouble, as well as 
providing additional functionality.

The problem appears to be line 16 of socketmodule.h, 
which includes WinSock 2 #if _MSC_VER >= 1300 and 
WinSock 1 otherwise. (IP_HDRINCL is a part of WinSock 
2.) Apply this patch to use WinSock 2 on MS VC++ 6 
(1200), which is what the Python Win32 builds are 
compiled with. (1300 is .Net? maybe?) pyconfig.h also 
needs to be patched.

Also, the _socket moduleneeds to link with ws2_32.lib 
instead of wsock32.lib. (Project -> Settings -> highlight 
_socket -> Win32 release -> Link tab -> 
in "Object/library modules" change wsock32.lib to 
ws2_32.lib).

With these changes, IP_HDRINCL exists in socket:

C:\>python
Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC 
v.1200 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import socket
>>> socket.IP_HDRINCL
2
>>>

And it works as it should, as do other obscure WinSock 2 
functions.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2004-09-18 18:18

Message:
Logged In: YES 
user_id=21627

I have changed _socket.vcproj 1.6 to link with ws2_32.lib
(and I wonder whether any library needs to be specified in
the project in the first place).

I'm rejecting this patch as out-of-date - the build
procedure for VC6 won't be changed, now that we have VC7.

----------------------------------------------------------------------

Comment By: Jeff Connelly aka shellreef (jeffconnelly)
Date: 2004-08-25 06:51

Message:
Logged In: YES 
user_id=31953

Python 2.4a2 fixes this issue somewhat, but not completely.
Since the Win32 release is compiled using Visual Studio 7.1,
the IP_HDRINCL and related symbols are defined.

However, socketmodule still links to wsock32.lib instead of
ws2_32.lib. This means that setsockopt(IP_HDRINCL) appears
to work, and even returns None, but it doesn't really work.
>From http://www2.2cah.com/ws2/log9706.txt :

> You're not doing anything wrong.  The problem is that,
unfortunately,
> Micorosoft's WinSock 2 doesn't support the IP_HDRINCL
socket option.
>
> They don't support IPPROTO_RAW ("raw IP") either. They
will gladly
> give you a socket, but then they send your IP header as
data, and
> send a bogus IP datagram that has 255--the value of
IPPROTO_RAW--
> as the protocol ID.  If you look at the net traffic that
results
> from this (with a net analyzer), you'd see the receiver of
this
> bogus datagram respond with a "Protocol Unreachable" ICMP
error
> message.
I haven't even succesfully sent raw sockets with wsock32.lib. 

This is fixed in ws2_32.lib. So all that Python has to do to
pull in these fixes is to link to wsock32.lib instead of
ws2_32.lib.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsacleanup_2.asp
says:
>Client: Requires Windows XP, Windows 2000 Professional, 
>Windows NT Workstation, Windows Me, Windows 98, or 
>Windows 95.
>[...]
>Library: Use Ws2_32.lib.
Therefore it leads me to believe that having Python link
with ws2_32.lib shouldn't cause any compatibility problems
on older systems, provided they have the Winsock2 updates.

If anyone is here, can we expect this patch to be merged soon?

Thanks,
-jc

----------------------------------------------------------------------

Comment By: Jeff Connelly aka shellreef (jeffconnelly)
Date: 2004-07-17 12:17

Message:
Logged In: YES 
user_id=31953

Can this change be merged into the current source tree? I 
need WinSock 2 for my application and distributing a patched 
version of Python isn't very elegant.

----------------------------------------------------------------------

Comment By: Jeff Connelly aka shellreef (jeffconnelly)
Date: 2004-03-03 00:20

Message:
Logged In: YES 
user_id=31953

P.S.: The original bug report is here:
https://sourceforge.net/tracker/index.php?
func=detail&aid=860134&group_id=5470&atid=105470

----------------------------------------------------------------------

Comment By: Jeff Connelly aka shellreef (jeffconnelly)
Date: 2004-03-03 00:18

Message:
Logged In: YES 
user_id=31953

P.S.: The original bug report is here:
https://sourceforge.net/tracker/index.php?
func=detail&aid=860134&group_id=5470&atid=105470

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=908631&group_id=5470


More information about the Patches mailing list