From: Matthew Bloch Date: 2002-05-06T18:33:56+09:00 Subject: getaddrinfo failing under Win32 [originally posted to the comp.os.ms.programmer.win32 newsgroup, but reposted here in case it's a Ruby-specific problem] Hi there; I'm finishing off a trivia game written in the Ruby language (www.ruby-lang.org) which will be running atop Windows NT/2000. Because the game is written in an interpreted language, the test versions of the game could be launched with a batch file which just reads: ruby-win32\rubyw.exe -r data_england -Igame -Iruby-win32 game\main.rb And the ruby-win32 directory contains all the necessary .DLLs and support libraries for the Ruby runtime. This works fine and the game launches. However, the software platform on which this is based demands that the 'runnable' part of the game be a single executable, so I figured I should write a simple launcher program which would execute a command defined in a text file. So I came up with this: #include #include int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { STARTUPINFO startupInfo; PROCESS_INFORMATION procInfo; BOOL success; FILE *fh; char cmd[512]; int r; fh = fopen("cmd.txt", "r"); if (fh == NULL) return 0; r = fread(cmd, 1, 512, fh); fclose(fh); r--; while (cmd[r] < 32) r--; cmd[r+1] = 0; GetStartupInfo(&startupInfo); success = CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, (char*) "PATH=ruby-win32\0\0", NULL, &startupInfo, &procInfo); if (success) WaitForSingleObject(procInfo.hProcess, INFINITE); return 0; } Which I compiled with: /usr/local/mingw32/bin/i386-mingw32-msvc-gcc \ -mwindows -o Launcher.exe Launcher.c And it seems to work fine if I try to run notepad, other Ruby scripts etc. by putting the command line string into cmd.txt and running Launcher.exe . However, the application needs to start a TCP server process, and part of this requires a call to getaddrinfo (TCPServer.new in Ruby). My problem is that this call succeeds when I launch the Ruby interpreter through a batch file, or at the command line, but fails with the error message "ai_family not supported" when launched through my launcher program. I'm fairly new to the Win32 API, so I'd appreciate any insight as to why this happens (on Windows 2000); is it due to a security restriction imposed on the child process? thanks, -- Matthew