Sriram Mokkapati wrote:

>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.
>
After fixing some syntax errors in your source file (no doubt introduced 
by mail systems having mangled it a bit), the program builds and runs 
fine for me.

I built the attached using VC++ 6.0 SP5 on WinXP SP1 using the command-line:

cl /IC:\perl5\lib\CORE foo.c /link ws2_32.lib C:\perl5\lib\CORE\perl58.lib

(I have perl-5.8.6 installed in C:\perl5), and the resulting foo.exe 
runs fine, outputting "Spot 0.Spot 1.Spot 2.Spot 3.Spot 4.Spot 5.".

I tried using both ActivePerl 5.8.6 Build 811 and my own build of 
perl-5.8.6 which is not threaded.  Both work fine.

What was your error message?  Your email didn't include the 
"PerlAndWinsockBomb.jpg" image.

- Steve


------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender 
immediately.  The unauthorized use, disclosure, copying or alteration of this 
message is strictly forbidden.  Note that any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of Radan Computational Ltd.  The recipient(s) of this message should 
check it and any attached files for viruses: Radan Computational will accept no 
liability for any damage caused by any virus transmitted by this email.
#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;
}

Reply via email to