home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3997 < prev    next >
Encoding:
Text File  |  1992-07-24  |  2.3 KB  |  58 lines

  1. Xref: sparky comp.unix.programmer:3997 comp.unix.questions:9541 comp.unix.wizards:3349 comp.sys.sun.misc:3386
  2. Path: sparky!uunet!dtix!darwin.sura.net!gatech!usenet.ins.cwru.edu!agate!flipper!richmond
  3. From: richmond@flipper (Stupendous Man)
  4. Newsgroups: comp.unix.programmer,comp.unix.questions,comp.unix.wizards,comp.sys.sun.misc
  5. Subject: Need help with socket problem on Sun
  6. Message-ID: <156n1pINNp0h@agate.berkeley.edu>
  7. Date: 29 Jul 92 18:12:09 GMT
  8. Organization: University of California, Berkeley
  9. Lines: 46
  10. NNTP-Posting-Host: flipper.berkeley.edu
  11.  
  12.  
  13. We are using a Sun Sparcstation II running Sun 4.1.2 UNIX to control our
  14. automatic telescope at the Astronomy department's Leuschner observatory.
  15. We have a very local Ethernet in which we send digital images from
  16. a PC or Mac into the Sun.  We are using sockets to read the data from the
  17. remote machine and write it to a Sun disk file.  Below is the code stub
  18. to do it.
  19.  
  20. #define BUF_SIZE 4096
  21.  
  22.     FILE *fp2;
  23.  
  24.     fp = open(fname, O_RDWR);          /* open local disk file */
  25.     fp2 = fopen("/dev/console", "w");    
  26.  
  27.  
  28.     InternetSocket = socket(AF_INET,SOCK_STREAM,0);  /* open Ethernet */
  29.     gethostbyname( ... );
  30.     connect ( ... );
  31.     while (not done) {
  32.          read(InternetSocket,data,BUF_SIZE);  /* suck in remote data */
  33.          write(fp, data, BUF_SIZE);           /* write to local disk */
  34. #ifdef FOO
  35.          fputc('.', fp2);             /* WRITE to console .. see below */
  36.          fflush(fp2);
  37. #endif
  38.    }
  39.  
  40.   Note the crazy write to the console, inside the '#ifdef FOO' section: 
  41. If we do not include it, it takes us 25 seconds to transfer 500kBytes; 
  42. if we do write to the console, it takes only 5 seconds!  
  43. The size of BUF_SIZE plays little role, nor do the
  44. types of machines on the other end.  We used to use an IBM RT running
  45. AIX to do the same thing  as the Sun (without printing to the screen) and
  46. it took about 8 seconds (mainly disk time).
  47.  
  48.   Our question is why this printout speeds things up so remarkably.  I would
  49. love to get rid of it since we get dots filling up our console screen
  50. whenever we take a picture (it also can crash Open Windows).
  51.  
  52.   Any stab in the dark would help.  Thanks in advance!
  53.  
  54. -- 
  55. --
  56. "Haven't you got better things to do        Michael Richmond
  57.  with your time than grope a cat?"          richmond@bkyast.berkeley.edu
  58.