<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2716.2200" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff size=2>It is
an old code. But it is very similar to BUG 1694. In my case, the client was not
a VB program, but the apache module mod_lisp. This module open socket connection
to another server to pass HTTP parameters from Apache to another server (A
Freepascal Program in my case :-) ). </FONT></SPAN></DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff size=2>I have
done it in LISP and VB without any problem. I have tried with FreePascal but
fail to do it :-(</FONT></SPAN></DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff size=2>!!!
Warning !!! Crappy test code ahead :-)</FONT></SPAN></DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------<SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------</FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff size=2>Uses
Sockets;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>Var<BR> lSock :
LongInt;<BR> uSock :
LongInt;<BR> sAddr : TInetSockAddr;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> lLen :
LongInt;<BR> sLine : String;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> SIn :
Text;<BR> SOut : Text;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> AAA : Boolean;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>Procedure PError (Const S : String);</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>Begin<BR> Writeln (S,
SocketError);<BR> Halt
(100);<BR>End;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>Begin<BR> lSock:=Socket (AF_Inet, Sock_Stream,
PF_Unspec);<BR> If SocketError<>0 Then PError
('Server : Socket : ');</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>
sAddr.Family:=AF_Inet;<BR> sAddr.Port :=lo (3000)
shl 8 or hi (3000);<BR> sAddr.Addr :=(1 shl 24) or
127;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> If Not Bind (lSock, sAddr, SizeOf (sAddr)) Then
PError ('Server : Bind : ');<BR> If Not Listen (lSock,
1) Then PError ('Server : Listen : ');</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>
Repeat<BR> Writeln
('Accepting
connection...');<BR> lLen
:=SizeOf (sAddr);<BR>
uSock:=Accept (lSock, sAddr,
lLen);<BR> If
SocketError<>0 Then PError ('Server : Accept :
');<BR> Writeln
('Connection accepted...');</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> Sock2Text (USock,
SIn, SOut); Write ('a');</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> Reset (SIn); Write
('b');<BR> Rewrite (SOut);
Write ('c');<BR>
AAA:=False;<BR> While Not
Eof (SIn) Do<BR>
Begin<BR>
ReadLn (SIn, sLine); write (sline,
';;');<BR>
If AAA=True
Then<BR>
Begin<BR>
AAA:=False;<BR>
Writeln ('url = ',
sLine);<BR>
End;<BR>
If sLine='url' Then
AAA:=True;<BR>
If sLine='end' Then
Break;<BR>
End;<BR> Write
('d');</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>
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>';</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> Writeln (SOut,
'Status');<BR> Writeln
(SOut, '200 OK');<BR>
Writeln (SOut,
'Content-Type');<BR>
Writeln (SOut,
'text/html');<BR> Writeln
(SOut,
'Content-Length');<BR>
Writeln (SOut, Length
(sLine)+2);<BR> Writeln
(SOut, 'Keep-Socket');<BR>
Writeln (SOut, '0');<BR>
writeln (SOut, 'end');<BR>
Writeln (SOut, sLine);</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> Close
(Sin);<BR> Close
(SOut);</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=770301710-18082002><FONT face=Arial color=#0000ff
size=2> ShutDown (uSock,
2);<BR> Until False;<BR>End.<BR></FONT></SPAN><SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2><SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff size=2>----------<SPAN
class=770301710-18082002><FONT face=Arial color=#0000ff
size=2>----------</FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Message d'origine-----<BR><B>De :</B>
fpc-pascal-admin@deadlock.et.tudelft.nl
[mailto:fpc-pascal-admin@deadlock.et.tudelft.nl]<B>De la part de</B> Peter
H.M. Brooks<BR><B>Envoyé :</B> dimanche 18 août 2002
00:31<BR><B>À :</B>
fpc-pascal@deadlock.et.tudelft.nl<BR><B>Objet :</B> Re:
[fpc-pascal]Sockets<BR><BR></FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=thierry.cabuzel@skynet.be
href="mailto:thierry.cabuzel@skynet.be">Thierry Cabuzel</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fpc-pascal@deadlock.et.tudelft.nl
href="mailto:fpc-pascal@deadlock.et.tudelft.nl">fpc-pascal@deadlock.et.tudelft.nl</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, August 18, 2002 12:19
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [fpc-pascal]Sockets</DIV>
<DIV><BR></DIV>
<DIV><SPAN class=930261722-17082002><FONT face=Arial color=#0000ff size=2>If
someone have sothing like this I would be pleased too. I have already tried
to do something like this and fall. The client connect to the server, send
the first packet, close the connection, reopen another connection, and send
another packet. At this point the server only receive garbage
:-(</FONT></SPAN></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2></FONT> </DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT
size=2></FONT> </DIV></BLOCKQUOTE>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2>Do you have some code and
a log? </FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2></FONT> </DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2>I am surprised, though
that you close the connection. Surely, for the duration of the conversation,
you should hold the connection open - if you are using TCP, that is. With UDP
you would expect one packet per conversation and it shouldn't matter if you
close the connection (in fact you don't have a connection end to end, only a
local connection).</FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2></FONT> </DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2>Actually, maybe that is
your problem (though the code would be needed to know). With UDP you only send
one packet and it is a connection less conversation - it is up to the higher
levels to establish a re-try or other packet loss mechanism.</FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2></FONT> </DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2>It would be good to hear
from somebody who has had both a TCP and a UDP protocol working.</FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT size=2></FONT> </DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT
size=2>Peter</FONT></DIV></BLOCKQUOTE></BODY></HTML>