www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - SocketException with code 10106

reply Emil Ivanov <emil.vladev gmail.com> writes:
Hi,

I'm trying to write something very simple using D and sockets.
I'm creating a socket like this:
auto s = new TcpSocket;

But here I get a SocketException with message "Unable to create socket" and
code 10106

The application compiles just fine, I have linked with ws2_32.lib, but I get
this error.

The environment is Windows XP Home SP2 with D 1.010.

Regards,
Emil Ivanov
May 18 2007
parent Regan Heath <regan netmail.co.nz> writes:
Emil Ivanov Wrote:
 Hi,
 
 I'm trying to write something very simple using D and sockets.
 I'm creating a socket like this:
 auto s = new TcpSocket;
 
 But here I get a SocketException with message "Unable to create socket" and
code 10106
 
 The application compiles just fine, I have linked with ws2_32.lib, but I get
this error.
 
 The environment is Windows XP Home SP2 with D 1.010.
The error code from MSDN: WSAEPROVIDERFAILEDINIT 10106 Service provider failed to initialize. The requested service provider could not be loaded or initialized. This error is returned if either a service provider's DLL could not be loaded (LoadLibrary failed) or the provider's WSPStartup or NSPStartup function failed. (I got WSAEPROVIDERFAILEDINIT by looking in dm\include\win32\winsock2.h then I searched MSDN online for the text) Now, std.socket calls WSAStartup, not WSPStartup or NSPStartup so I suspect the DLL is failing to load perhaps. The constructor for class Socket, called by TcpSocket calls the Win32 function 'socket' which on MSDN does not even mention the possibility of that error. Try linking with wsock32.lib instead, and make sure you're linking with the one in the dm\lib directory. Regan Heath
May 18 2007