[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] C++ sockets



> From sslug@sslug  Sun May 12 00:00:19 2002
> Subject: [CPROG] C++ sockets
>
> Hej,
>
> jeg har oprettet en socket forbindelse, hvor jeg prøver at hente fra en
> angiven server.
> Når jeg har oprettet forbindelsen og sender en HTTP request afsted, og
> prøver at læse fra filedescriptoren, så modtager jeg ikke alle de data jeg
> skulle.
> bufferen som jeg bruger i read() kaldet er væsentlig større end det jeg
> burde modtage.
>
> Er der en der har en forklaring?
>

Det tror jeg. Det du modtager er ikke noedvendigvis det du beder om,
men det som lige passer ind i kernens opfattelse af hvad du kan faa
i en bid.

Du faa retur hvad du modtager, og hvis du proever at modtage igen,
faar du mere data.

Saks fra man recv:
      If  no  messages  are available at the socket, the receive
      calls wait for a message to arrive, unless the  socket  is
      nonblocking  (see  fcntl(2)) in which case the value -1 is
      returned and the external variable errno  set  to  EAGAIN.
      The  receive  calls normally return any data available, up
      to the requested amount, rather than waiting  for  receipt
      of the full amount requested.
								 

En af de foerste oevelser man skal lave med sockets er at proeve at
implementere en metode, som returnerer praecis saa meget som man
beder om.

I HTTP er der to maader at faa den slags information. Hvis der er
tale om HTTP/1.0, lukkes forbindelsen naar der ikke er mere data.

I HTTP/1.1 faar du ogsaa en Content-Length header. (Samt forbindelsen
lukkes.)

Haaber det hjaelper. Det er lidt kort, men sockets er non-trivielle.

Soeg evt efter Beej's Guide to Network Programming. Det er den jeg
laeste da jeg startede med sockets.

-- 
   _______
  /       \    Michael Westergaard <sslug@sslug>
 / /|/|  \ \   http://klafbang.dk/
( ( ` |   ) )
 \ \  |/\/ /   Mit ur går stadig efter vintertid. Det giver en
  \_______/    dejlig, men falsk, følelse af at have god tid.


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