[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



Björn Lundin wrote:
> 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.
>
>
>   
Det har du ret i men det er jo også ada. Jeg ved ikke om Ada giver dig
alt hvad der er at læse med et kald til read, men det gør C jo ikke. Så
der vil man skulle fylde sin buffer flere gange, og på et tidspunkt er
der ikke mere. Det kan du kun opdage ved at læse igen, og hvis din
socket så blokerer kan det være et problem.


 
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] *