SocketException with code 10106

Regan Heath regan at netmail.co.nz
Fri May 18 14:46:57 PDT 2007


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



More information about the Digitalmars-d mailing list