\r
beware (20030905)\r
* if connect failed (conn refused) set state to connected and call internalclose, to get closed handler (instead of fdclose)\r
-* (lcore) if closing the fd's in internalcose, set fd's to -1 because closing an fd makes it invalid\r
+* (lcore) if closing the fd's in internalclose, set fds to -1 because closing an fd makes it invalid\r
\r
beware (20030927)\r
* fixed: on connect failed, tried to close fdhandle's which were already set to -1, added check\r
\r
//host : THostentry ;\r
\r
- //mainthread : boolean ; //for debuggin only\r
+ //mainthread : boolean ; //for debugging only\r
addr:thostname;\r
port:ansistring;\r
localaddr:thostname;\r
if fdhandlein >= 0 then begin\r
{one *can* get here without fd -beware}\r
eventcore.rmasterclr(fdhandlein);\r
- myfdclose(fdhandlein); // we musnt leak file discriptors\r
+ myfdclose(fdhandlein); // we musnt leak file descriptors\r
eventcore.setfdreverse(fdhandlein,nil);\r
fdhandlein := -1;\r
end;\r
\r
function tlsocket.accept : longint;\r
var\r
- FromAddrSize : LongInt; // i don't realy know what to do with these at this\r
+ FromAddrSize : LongInt; // i don't really know what to do with these at this\r
FromAddr : TInetSockAddrV; // at this point time will tell :)\r
- a:integer;\r
+ a,acceptlasterror:integer;\r
begin\r
{$ifdef secondlistener}\r
if (lastsessionfromsecond) then begin\r
{$else}\r
result := system_accept(fdhandlein,fromaddr,fromaddrsize);\r
{$endif}\r
+\r
+ if (result = -1) then acceptlasterror := {$ifdef mswindows}getlasterror{$else}socketerror{$endif} else acceptlasterror := 0;\r
+\r
//now we have accepted one request start monitoring for more again\r
eventcore.rmasterset(fdhandlein,true);\r
\r
if result = -1 then begin\r
- raise esocketexception.create('error '+inttostr({$ifdef mswindows}getlasterror{$else}socketerror{$endif})+' while accepting');\r
+ raise esocketexception.create('error '+inttostr(acceptlasterror)+' while accepting');\r
end;\r
- if result > absoloutemaxs then begin\r
+ if result > absolutemaxs then begin\r
myfdclose(result);\r
a := result;\r
{ result := -1;}\r
- raise esocketexception.create('file discriptor out of range: '+inttostr(a));\r
+ raise esocketexception.create('file descriptor out of range: '+inttostr(a));\r
end;\r
end;\r
\r
exit;\r
end;\r
if (state =wsconnecting) and writetrigger then begin\r
- // code for dealing with the reults of a non-blocking connect is\r
+ // code for dealing with the results of a non-blocking connect is\r
// rather complex\r
- // if just write is triggered it means connect suceeded\r
+ // if just write is triggered it means connect succeeded\r
// if both read and write are triggered it can mean 2 things\r
- // 1: connect ok and data availible\r
+ // 1: connect ok and data available\r
// 2: connect fail\r
// to find out which you must read from the socket and look for errors\r
- // there if we read successfully we drop through into the code for fireing\r
+ // there if we read successfully we drop through into the code for firing\r
// the read event\r
if not readtrigger then begin\r
state := wsconnected;\r
exit;\r
end;\r
// if things went well here we are now in the state wsconnected with data sitting in our receive buffer\r
- // so we drop down into the processing for data availible\r
+ // so we drop down into the processing for data available\r
end;\r
if fdhandlein >= 0 then begin\r
if state = wsconnected then begin\r