/[lcore]/trunk/lsocket.pas
ViewVC logotype

Diff of /trunk/lsocket.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 135 by beware, Thu Mar 13 21:27:50 2014 UTC revision 136 by beware, Fri Mar 28 03:18:52 2014 UTC
# Line 22  Line 22 
22    
23  beware (20030905)  beware (20030905)
24  * if connect failed (conn refused) set state to connected and call internalclose, to get closed handler (instead of fdclose)  * if connect failed (conn refused) set state to connected and call internalclose, to get closed handler (instead of fdclose)
25  * (lcore) if closing the fd's in internalcose, set fd's to -1 because closing an fd makes it invalid  * (lcore) if closing the fd's in internalclose, set fds to -1 because closing an fd makes it invalid
26    
27  beware (20030927)  beware (20030927)
28  * fixed: on connect failed, tried to close fdhandle's which were already set to -1, added check  * fixed: on connect failed, tried to close fdhandle's which were already set to -1, added check
# Line 93  Line 93 
93    
94        //host               : THostentry      ;        //host               : THostentry      ;
95    
96        //mainthread         : boolean         ; //for debuggin only        //mainthread         : boolean         ; //for debugging only
97        addr:thostname;        addr:thostname;
98        port:ansistring;        port:ansistring;
99        localaddr:thostname;        localaddr:thostname;
# Line 497  Line 497 
497        if fdhandlein >= 0 then begin        if fdhandlein >= 0 then begin
498          {one *can* get here without fd -beware}          {one *can* get here without fd -beware}
499          eventcore.rmasterclr(fdhandlein);          eventcore.rmasterclr(fdhandlein);
500          myfdclose(fdhandlein); // we musnt leak file discriptors          myfdclose(fdhandlein); // we musnt leak file descriptors
501          eventcore.setfdreverse(fdhandlein,nil);          eventcore.setfdreverse(fdhandlein,nil);
502          fdhandlein := -1;          fdhandlein := -1;
503        end;        end;
# Line 532  Line 532 
532    
533  function tlsocket.accept : longint;  function tlsocket.accept : longint;
534  var  var
535    FromAddrSize     : LongInt;        // i don't realy know what to do with these at this    FromAddrSize     : LongInt;        // i don't really know what to do with these at this
536    FromAddr         : TInetSockAddrV;  // at this point time will tell :)    FromAddr         : TInetSockAddrV;  // at this point time will tell :)
537    a:integer;    a:integer;
538  begin  begin
# Line 556  Line 556 
556    if result = -1 then begin    if result = -1 then begin
557      raise esocketexception.create('error '+inttostr({$ifdef mswindows}getlasterror{$else}socketerror{$endif})+' while accepting');      raise esocketexception.create('error '+inttostr({$ifdef mswindows}getlasterror{$else}socketerror{$endif})+' while accepting');
558    end;    end;
559    if result > absoloutemaxs then begin    if result > absolutemaxs then begin
560      myfdclose(result);      myfdclose(result);
561      a := result;      a := result;
562  {    result := -1;}  {    result := -1;}
563      raise esocketexception.create('file discriptor out of range: '+inttostr(a));      raise esocketexception.create('file descriptor out of range: '+inttostr(a));
564    end;    end;
565  end;  end;
566    
# Line 673  Line 673 
673      exit;      exit;
674    end;    end;
675    if (state =wsconnecting) and writetrigger then begin    if (state =wsconnecting) and writetrigger then begin
676      // code for dealing with the reults of a non-blocking connect is      // code for dealing with the results of a non-blocking connect is
677      // rather complex      // rather complex
678      // if just write is triggered it means connect suceeded      // if just write is triggered it means connect succeeded
679      // if both read and write are triggered it can mean 2 things      // if both read and write are triggered it can mean 2 things
680      // 1: connect ok and data availible      // 1: connect ok and data available
681      // 2: connect fail      // 2: connect fail
682      // to find out which you must read from the socket and look for errors      // to find out which you must read from the socket and look for errors
683      // there if we read successfully we drop through into the code for fireing      // there if we read successfully we drop through into the code for firing
684      // the read event      // the read event
685      if not readtrigger then begin      if not readtrigger then begin
686        state := wsconnected;        state := wsconnected;
# Line 697  Line 697 
697          exit;          exit;
698        end;        end;
699        // if things went well here we are now in the state wsconnected with data sitting in our receive buffer        // if things went well here we are now in the state wsconnected with data sitting in our receive buffer
700        // so we drop down into the processing for data availible        // so we drop down into the processing for data available
701      end;      end;
702      if fdhandlein >= 0 then begin      if fdhandlein >= 0 then begin
703        if state = wsconnected then begin        if state = wsconnected then begin

Legend:
Removed from v.135  
changed lines
  Added in v.136

No admin address has been configured">No admin address has been configured
ViewVC Help
Powered by ViewVC 1.1.22