[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] C++ Socket programmering, client, test af connection



Robert Larsen wrote:


> Hvis man bruger blokerende sockets riscikerer man at komme til at vente
> i et read kald (eller write).

?

Lite pseudo-ada kod

      case Sockets.Selects(Channel.Fd, Int_Time_Out) is
        when Posix1.Int'first .. -1  => raise Get_Error;
        when 0                       => raise Input_Timeout;
        when others                  => null;
      end case;
      Posix1.Read(Channel.Fd, Buffer(1..1), Nbyte);

      if Nbyte <= 0 then
        raise Get_Error;
      end if;
      Input := Byte(Buffer(1));

dvs anrop till select,
om result >= -1 så har vi ett fel
om result = 0 så har inget hänt på socketen på Int_Time_Out tid
om result > 0 så har något hänt på Result många socketar
En recv på socketen (om bara en i select-setet, och vi gör select på read) 
_kommer_ att lyckas, dvs inte blockera. 

Som vanligt, om vi får 0 från recv, har andra sidan kopplat ned.


-- 
/Björn



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *