[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: your mail



  Article: <sslug@sslug>
  Date:    Fri, 11 Jun 1999 12:21:53 +0200 (CEST)
  Author:  Jesper Monsted <sslug@sslug>

> hmmm, er der en statusbesked i hver linie eller er det en besked med tre
> liniers tekst? Hvis det er det sidste kan du måske læse statusnummer og
> ignorere et fast antal linier alt efter hvad nummer det er (virker
> selvfølgelig kun hvis der kommer samme antal linier hver gang). En anden
> løsning kunne være at læse første tegn i linien, hvis det er et tal læser
> man resten af koden og smider resten af linien væk, hvis det er et bogstav
> smider man linien i havet med det samme.
> 

Problemet är inte metoden att läsa in raderna, jag skulle kunna använda
large_buffer[BUFSIZ] och sen bara läsa in de första X byten. Det jag
skulle vilja göra är så här:


textrad:
0123456789 abcdefghijklmno\n

char small_buffer[10]
read(socket_fd, small_buffer, 10);

nu befinner jag mig här:
0123456789 abcdefghijklmno\n
          ^ 

motsvarande till lseek(socket_fd, 0, SEEK_END) utförs:
(om det är multipla rader vill jag förstås ända hoppa till efter sista
tecknet)  

nu befinner jag mig här:
0123456789 abcdefghijklmno\n
                            ^

write(socket_fd, some_other_buffer, strlen(some_other_buffer))

ny textrad:

9876543210 onmlkjihgfedcba\n

read(socket_fd, small_buffer, 10);

nu befinner jag mig här:
9876543210 onmlkjihgfedcba\n
          ^
lseek(socket_fd, 0, SEEK_END)
nu befinner jag mig här:
9876543210 onmlkjihgfedcba\n
                            ^

0123456789 abcdefghijklmno\n9876543210 onmlkjihgfedcba\n
          ^                 ^         ^                 ^
	  1 läsning         2 lseek   3 läsning         4 lseek              


Det kanske är omöjligt att åstadkomma.


Magnus


--
Magnus Sjögren <sslug@sslug>



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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