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