On Wed, Jul 09, 2003 at 07:12:34PM -0400 Joe Flowers wrote:

> 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.

The reason might be that perl.h includes iperlsys.h which itselfs
has a typedef for SOCKET.

> Please help. Any ideas or thoughts or intuitions will be appreciated.
> 
> Joe
> 
> //----------------------------------------------------------
> #include <windows.h>
> #include <stdio.h>
> 
> #include <EXTERN.h>
> #include <perl.h>

Will it help if you swap the includes? First include EXTERN.h and perl.h
and then all the other headers files. That might already be enough.

> //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("\nSpot 0.");
> 
> ccode = WSAStartup(version, &wsaData);
> if(wsaData.wVersion != version)     {
> printf("\nWrong Winsock version."); }
> 
> printf("\nSpot 1.");
> 
> listenSocket = socket(AF_INET, SOCK_STREAM,IPPROTO_TCP);
> 
> printf("\nSpot 2.");
> 
> if(listenSocket==INVALID_SOCKET) {
> printf("\nsocket() error.");     }
> 
> printf("\nSpot 3.");
> closesocket(listenSocket);
> 
> printf("\nSpot 4.");
> WSACleanup();
> 
> printf("\nSpot 5.");
> return 0;
> }
> //----------------------------------------------------------
> //End.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to