[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: [CPROG] Broken pipe?



"Thomas Salling" <sslug@sslug> writes:

> Jeg har et stykke kode som connecter til en sever og henter data (en
> wget-agtig webcrawler på et meget tidligt stadie). Det ser ud ca. 
> sådan her:
 
>  connect(msocket, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr));

Check resultatet. Det kan være at din connect fejler med det samme.

>  if( select((msocket+1), NULL, &contime, NULL, &tv) > 0 )
>  {
>   if( (FD_ISSET(msocket, &contime)) > 0 )
>   {
>     ... her burde vi være nogenlunde sikre på at der kan skrives til den socket (og at den er connected).

Nej; når din socket er writable har du enten fået forbindelse _eller_
der opstod en asynkron fejl. Så skal du hente en evt fejl status med
getsockopt SOL_SOCKET SO_ERROR for at skelne mellem de 2 situationer.

>     error = send(msocket, request, strlen(request), 0);

Det er ikke sikkert send() har formået at sende det hele -- specielt
når det er tale om en NB socket. Sammenlign resultatet af send() med
det du vil sende og blive ved (fra det rette sted) hvis ikke du har
sendt det hele. Hvis du vil have timeouts bør du selvfølgelig gøre det
vha select.

> Jeg har en global signal handler som jeg plejer at bruge til at
> fange de få broken pipes der normalt kommer. Måske det er her
> problemet ligger? Jeg mener dog stadig ikke at der bør komme så
> mange EPIPE fejl selvom jeg ikke fanger dem?

Bare ignorer (SIG_IGN) SIGPIPE for at lave den om til EPIPE. Du får
denne når du forsøger at skrive til en lukket pipe (eller socket).

-- 
===============================================================
<sslug@sslug>                           Herlev, Denmark     
<URL:http://www.andreasen.org/>                             <*>   
===============================================================



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 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] *