[Win32utils-devel] WSAStartup failure

Heesob Park phasis at gmail.com
Tue Feb 8 01:02:53 EST 2011


Hi,

2011/2/8 Daniel Berger <djberg96 at gmail.com>:
> Hi,
>
> I added the Windows::WSA module to windows-pr recently (it's in the latest
> git repo). However, I can't seem to make WSAStartup work. I tried the
> following bit of code, only to get "The Windows Sockets version requested is
> not supported" on my Vista box.
>
> Is it really not supported on Vista? The docs say Win2k or later. Or is
> there another issue?
>
> require 'windows/wsa'
> require 'windows/error'
> require 'windows/system_info'
>
> include Windows::WSA
> include Windows::Error
> include Windows::SystemInfo
>
> begin
>  version = MAKEWORD(2,2)
>  buffer = 0.chr * 532
>  err = WSAStartup(version, buffer)
>
>  if err != 0
>    puts "Oops: " + get_last_error(err)
>  end
> ensure
>  WSACleanup()
> end
>
The current definition of MAKEWORD and MAKELONG is wroing.

Here is fixed version of MAKEWORD and MAKELONG.

def MAKEWORD(a, b)
      ((a & 0xff) | ((b & 0xff) << 8))
end
def MAKELONG(a, b)
      ((a & 0xffff) | ((b & 0xffff) << 16))
end


Regards,
Park Heesob


More information about the win32utils-devel mailing list