[fpc-pascal] How to close TInetServer without except?

silvioprog silvioprog at gmail.com
Mon May 6 07:17:35 CEST 2013


2013/5/5 Ludo Brands <ludo.brands at free.fr>

> On 05/04/2013 09:59 PM, Zaher Dirkey wrote:
>
> > now in this example
> >
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms737526%28v=vs.85%29.aspx
> > They not use Select before accept
> >
>
> If you are happy with accept blocking or if you use non-blocking sockets
> you don't need select before accept.
>
> > and in
> >
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms740141%28v=vs.85%29.aspx
> >
> >>The parameter /readfds/ identifies the sockets that are to be checked
> > for readability. If the socket is currently in the *listen*
> > <
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms739168%28v=vs.85%29.aspx
> >
> > state, it will be marked as readable if >an incoming connection request
> > has been received such that an *accept*
> > <
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms737526%28v=vs.85%29.aspx
> >
> > is guaranteed to complete *without blocking*.
> >
>
> That is exactly the purpose of select. The timeout guarantees that your
> program stays alive and can do something else.
>
> > I still not sure in windows need Select, but maybe in Linux only, but i
> > can't test it there.
> >
>
> I repeat, you don't have to use select in Windows or Linux. If you
> prefer blocking sockets you don't need select but accept/recv/send will
> block. If you use non-blocking sockets you need to deal with EAGAIN or
> EWOULDBLOCK (WSAEWOULDBLOCK on windows). There are also alternatives to
> select: poll, epoll, libevent, etc., etc. on linux, WSAPoll on windows
> Vista and later. For completeness, on windows you have also the
> asynchronous overlapped IO mode which is used a lot in high performance
> servers but rather complex to program.
>
> Ludo


Ludo, I'm almost by completing the units in this link:

https://bitbucket.org/silvioprog/tcpipcomp (this repository is temporary)

The current code (I'm updating it daily) in these units is good? I'm open
to suggestions, and we can change whatever it takes.

I want to send these units to the Free Pascal team and a package to the
Lazarus team.

Sorry for my English please.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130506/1e139de9/attachment.html>


More information about the fpc-pascal mailing list