In the context of a single-threaded server such as you might construct in the absence of fork() on Win32, using mingw and winsock2.h; and suppose you only intend to cater for a single connection, so instead of having a sockets[] array for all the client sockets, you just have one int thesocket.
Do not do an FD_SET(thesocket, &read_fdset), when preparing to select, if thesocket is 0 (as it might be if you haven't had a connection yet or have closed one). This does not, as I expected, harmlessly AND 0 onto the fd_set, it appears to bugger it up completely so select() returns -1 without even waiting.
('Harmlessly AND 0' indeed. I was mixing up AND and OR there)
Also note that a single-threaded server that only expects one connection has to actively reject further connection attempts - you will find that FD_SET(serversocket, &read_fdset) is true after select() on every such attempt. To reject them, just closesocket() them.
Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )
Followers
Blog Archive
-
▼
2012
(63)
-
▼
February
(13)
- ssh chain tunnelling
- plink
- SQL Server functions
- Window functions in updates
- Turn off OpenOffice Calc AutoCorrect
- Perl missing comma gotcha
- Perl Win32::GUI Terminate
- Perl::Tk hide window with withdraw
- Sockets with select
- Perl easy extensions
- Perl Win32::OLE
- OpenSSH with a domain
- SSH servers for Windows
-
▼
February
(13)