Project

General

Profile

Actions

Bug #12033

closed

WSASocket can't work with Ruby extensions.

Added by nicolasnoble (Nicolas Noble) about 8 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x64-mingw32]
[ruby-core:73574]

Description

Basically, when creating a gem with C code that tries to do a WSASocket() call, the socket will end up being non-viable. I have tried this using the native DevKit compiler, rake-compiler-dock, ruby 2.2, 2.1, 32 and 64 bits, to no avail. If a C extension calls into socket(), that socket will work, but if it calls into WSASocket(), it somehow won't.

I have attached an example of a very simple gem, which is basically the sample code from https://msdn.microsoft.com/en-us/library/windows/desktop/ms737550(v=vs.85).aspx

In the first test, calling into socket() and binding that socket to localhost will work. In the second test, calling into WSASocket() will return a socket, but then binding it won't work, with a WSAENOTSOCK error.

If you add a main() function that simply calls into the Init_foobar() function, and compile it into a normal exe file, both tests will work normally.

My guess is that the ruby environment is doing something... weird ? And as a result, the winsock system is altered in a way that makes WSASocket unviable.


Files

foobar.zip (2.68 KB) foobar.zip nicolasnoble (Nicolas Noble), 01/29/2016 10:32 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0