[fpc-pascal]Difficulties to post a bug report
Thierry Cabuzel
thierry.cabuzel at skynet.be
Mon Mar 11 19:15:47 CET 2002
I have the impossibility to post a bug report. Why ? I don't know.
Here it is:
------------ REPORT
I have some inconsistency with sockets under windows. Here the setup: Win
(98/nt), Apache, Mod_lisp, a freepascal program. See a minimalist one
attached. This one receive the get request, display parameters received and
return a static page.
Mod_lisp is a kind of fast-cgi protocol on socket but way easyer than the
true fastcgi.
Well, from time to time the first request done to apache is correctly
received by the program, but the second transmission is always wrong. I
receive garbage caracters...
Note: When I replace the freepascal program with a VB or Lisp one, I have no
problem.
I think this problem is linked with the problem 1694, but I am not sure.
------------ SOURCE
Uses Sockets;
Var
lSock : LongInt;
uSock : LongInt;
sAddr : TInetSockAddr;
lLen : LongInt;
sLine : String;
SIn : Text;
SOut : Text;
AAA : Boolean;
Procedure PError (Const S : String);
Begin
Writeln (S, SocketError);
Halt (100);
End;
Begin
lSock:=Socket (AF_Inet, Sock_Stream, PF_Unspec);
If SocketError<>0 Then PError ('Server : Socket : ');
sAddr.Family:=AF_Inet;
sAddr.Port :=lo (3000) shl 8 or hi (3000);
sAddr.Addr :=(1 shl 24) or 127;
If Not Bind (lSock, sAddr, SizeOf (sAddr)) Then PError ('Server : Bind
: ');
If Not Listen (lSock, 1) Then PError ('Server : Listen : ');
Repeat
Writeln ('Accepting connection...');
lLen :=SizeOf (sAddr);
uSock:=Accept (lSock, sAddr, lLen);
If SocketError<>0 Then PError ('Server : Accept : ');
Writeln ('Connection accepted...');
Sock2Text (USock, SIn, SOut);
Reset (SIn);
Rewrite (SOut);
AAA:=False;
While Not Eof (SIn) Do
Begin
ReadLn (SIn, sLine);
WriteLn (sLine);
If AAA=True Then
Begin
AAA:=False;
Writeln ('url = ', sLine);
End;
If sLine='url' Then AAA:=True;
If sLine='end' Then Break;
End;
sLine:='<!DOCTYPE HTML PUBLIC "-//IETF//DTD
HTML//EN"><HTML><HEAD></HEAD><BODY><H1>mod_lisp 2.0b2</H1><P>This is a
constant html string sent by Apache + mod_lisp 2.0b2 + FreePascal +
Windows</P></BODY></HTML>';
Writeln (SOut, 'Status');
Writeln (SOut, '200 OK');
Writeln (SOut, 'Content-Type');
Writeln (SOut, 'text/html');
Writeln (SOut, 'Content-Length');
Writeln (SOut, Length (sLine)+2);
Writeln (SOut, 'Keep-Socket');
Writeln (SOut, '0');
writeln (SOut, 'end');
Writeln (SOut, sLine);
Close (Sin);
Close (SOut);
ShutDown (uSock, 2);
Until False;
End.
More information about the fpc-pascal
mailing list