Hi all please give me a solution for this [Originally posted by joeflowers]
Help please. Below is a small simple C program created with MS Visual C++ v6sp5. When the EXE (saserver.exe) is run on 2 different MS Windows XPsp1 machines, the program crashes - see the attached "PerlAndWinsockBomb.jpg" image. If I take out the "#include <perl.h>" line OR if I take out the the "listenSocket = socket(AF_INET, SOCK_STREAM,IPPROTO_TCP);" line and recompile/link, then the program does not crash - it finishes without a problem. The embedded Perl code (not included) that I *must have* the "#include <EXTERN.h>" and "#include <perl.h>" lines for works fine in any C code I build that does not have any C Winsock socket calls in them. However, the embedded Perl code seems irrelevant to this particular email message since I can't even include (#include <perl.h> it's prerequisites without the program crashing. Please help. Any ideas or thoughts or intuitions will be appreciated. Joe //---------------------------------------------------------- #include <windows.h> #include <stdio.h> #include <EXTERN.h> #include <perl.h> //Link with: Kernel32.lib, LIBCMT.LIB, perl58.lib (or perl56.lib), WS2_32.Lib //saserver.def contains the following single line. //STACKSIZE 30000000 int main() { SOCKET listenSocket = 0; int ccode = 0; WSADATA wsaData; WORD version = MAKEWORD(2,2); printf(" Spot 0."); ccode = WSAStartup(version, &wsaData); if(wsaData.wVersion != version) { printf(" Wrong Winsock version."); } printf(" Spot 1."); listenSocket = socket(AF_INET, SOCK_STREAM,IPPROTO_TCP); printf(" Spot 2."); if(listenSocket==INVALID_SOCKET) { printf(" socket() error."); } printf(" Spot 3."); closesocket(listenSocket); printf(" Spot 4."); WSACleanup(); printf(" Spot 5."); return 0; } //---------------------------------------------------------- //End.