Click to See Complete Forum and Search --> : Calling Windows Socket routines from a PHP Extension DLL?


grue
09-26-2002, 02:46 AM
I have written an C-language extension DLL for PHP, and I am having some trouble opening a socket() inside this DLL.

If I call:


SOCKET socket = socket(AF_INET, SOCK_STREAM, 0 /* IPPROTO_TCP */);


I get an invalid socket back. WSAGetLastError() is 10106, or "The requested service provider could not be loaded or initialized".

Before this call, I call WSAStartup() asking for version 2.0, and that returns OK.

Even if I don't call WSAStartup() (thinking the socket stuff may have been initialized by the PHP runtime), I still get the 10106 error back from the socket() call.

Anyone have any tips on how to make socket calls from within a PHP extension DLL, or clue as to what I'm doing wrong?

grue
09-26-2002, 03:09 AM
Apparently, I need to have "SYSTEMROOT" set in my environment, or the WinSock calls don't work...

Normally this variable is inherited from the Windows environment, but as PHP.exe is being called as a CGI with CreateProcess() with its own env, this variable was missing.

dotwebbie
09-26-2002, 12:13 PM
So, is this solved?