<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Hmm there is diffrents<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Yours<br>res:=select(sock+1,@readfds,@writefds,@exceptfds,@tv);<br>
</div><div class="gmail_default" style="font-family:tahoma,sans-serif">Mine<br>c := WinSock2.select(0, PSetRead, PSetWrite, nil, @TimeVal);<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">0 here in mine, in yours sock+1 (FHandle+1 in mine).<br>
</div><div class="gmail_default" style="font-family:tahoma,sans-serif">I will take more testing.<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 4, 2013 at 8:01 PM, Ludo Brands <span dir="ltr"><<a href="mailto:ludo.brands@free.fr" target="_blank">ludo.brands@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 05/04/2013 05:05 PM, Zaher Dirkey wrote:<br>
><br>
> On Sat, May 4, 2013 at 5:40 PM, Ludo Brands <<a href="mailto:ludo.brands@free.fr">ludo.brands@free.fr</a><br>
</div><div class="im">> <mailto:<a href="mailto:ludo.brands@free.fr">ludo.brands@free.fr</a>>> wrote:<br>
><br>
> Can you show the code you use? You tested on Windows, linux, Mac, ...?<br>
><br>
><br>
> Only on Windows XP<br>
><br>
<br>
<br>
</div>This is a small test program that works for me on XP and linux:<br>
<br>
program testselect;<br>
<br>
{$mode objfpc}{$H+}<br>
<br>
uses<br>
Classes,sockets,<br>
{$ifdef unix}<br>
unix,baseunix,unixtype<br>
{$else}<br>
ctypes,WinSock2<br>
{$endif}<br>
;<br>
<br>
CONST<br>
LISTENPORT=1234;<br>
var<br>
sock: cint;<br>
sa,clsa:sockaddr;<br>
tv:TTimeVal;<br>
readfds,writefds,exceptfds:tfdset;<br>
c: Integer;<br>
res: cint;<br>
len: tsocklen;<br>
one: Integer;<br>
begin<br>
sock:=fpsocket(AF_INET, SOCK_STREAM, 0);<br>
if sock=-1 then<br>
begin<br>
writeln('socket failed with ',socketerror);<br>
exit;<br>
end;<br>
one:=1;<br>
if fpsetsockopt(sock, SOL_SOCKET, SO_REUSEADDR, @one, sizeof(one))=-1 then<br>
begin<br>
writeln('setsockopt failed with ',socketerror);<br>
exit;<br>
end;<br>
fillchar(sa,sizeof(sa),0);<br>
sa.sin_port:=htons(LISTENPORT);<br>
sa.sin_family:=AF_INET;<br>
sa.sin_addr.s_addr:= INADDR_ANY;<br>
if fpbind(sock,@sa,sizeof(sa))=-1 then<br>
begin<br>
writeln('bind failed with ',socketerror);<br>
exit;<br>
end;<br>
if fplisten(sock,10)=-1 then<br>
begin<br>
writeln('listen failed with ',socketerror);<br>
exit;<br>
end;<br>
c:=1;<br>
repeat<br>
tv.tv_sec:=1;<br>
tv.tv_usec:=0;<br>
{$ifdef unix}<br>
fpFD_ZERO(readfds);<br>
fpFD_ZERO(writefds);<br>
fpFD_ZERO(exceptfds);<br>
fpFD_SET(sock,readfds);<br>
res:=fpselect(sock+1,@readfds,@writefds,@exceptfds,@tv);<br>
if (res=-1) and (socketerror<>ESYSEINTR) then<br>
begin<br>
writeln('select failed with ',socketerror);<br>
exit;<br>
end;<br>
if (res>0) and (fpFD_ISSET(sock,readfds)<>0) then<br>
begin<br>
{$else}<br>
FD_ZERO(readfds);<br>
FD_ZERO(writefds);<br>
FD_ZERO(exceptfds);<br>
FD_SET(sock,readfds);<br>
res:=select(sock+1,@readfds,@writefds,@exceptfds,@tv);<br>
if (res=-1) and (socketerror<>WSAEINTR) then<br>
begin<br>
writeln('select failed with ',socketerror);<br>
exit;<br>
end;<br>
if (res>0) and (FD_ISSET(sock,readfds)) then<br>
begin<br>
{$endif}<br>
fillchar(clsa,sizeof(clsa),0);<br>
len:=sizeof(clsa);<br>
if fpaccept(sock,@clsa,@len)=-1 then<br>
begin<br>
writeln('accept failed with ',socketerror);<br>
exit;<br>
end;<br>
writeln('connection accepted');<br>
c:=c+1;<br>
end;<br>
until c=2;<br>
closesocket(sock);<br>
<br>
end.<br>
<br>
If you run the program and do from a console a<br>
telnet localhost 1234<br>
to connect to the program, it will print 'connection accepted' and close<br>
immediately.<br>
<div class="HOEnZb"><div class="h5"><br>
Ludo<br>
<br>
<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><span style="font-family:courier new,monospace">I am using last revision of Lazarus, FPC 2.6 on Windows XP SP3<br><br>Best Regards<br>Zaher Dirkey</span></div>
</div>