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 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal