From owner-freebsd-hackers Mon Dec 16 19:11:38 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id TAA21741 for hackers-outgoing; Mon, 16 Dec 1996 19:11:38 -0800 (PST) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id TAA21731 for ; Mon, 16 Dec 1996 19:11:35 -0800 (PST) Received: from hub.org (root@hub.org [207.107.138.200]) by who.cdrom.com (8.7.5/8.6.11) with ESMTP id SAA26868 for ; Mon, 16 Dec 1996 18:40:36 -0800 (PST) Received: from localhost (scrappy@localhost) by hub.org (8.8.2/8.7.5) with SMTP id VAA17390; Mon, 16 Dec 1996 21:38:36 -0500 (EST) Date: Mon, 16 Dec 1996 21:38:34 -0500 (EST) From: "Marc G. Fournier" To: Terry Lambert cc: hackers@FreeBSD.ORG Subject: Re: Almost have mmap() figured, I think... In-Reply-To: <199612170201.TAA07421@phaeton.artisoft.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Mon, 16 Dec 1996, Terry Lambert wrote: > start = mmap( 0, FRAMESIZE * FRAMES, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)); > for( i = 0; i < FRAMES; i++) > frame[i] = start + i * FRAMESIZE; > Okay, that one makes sense... Then, would it make sense to also have: size = mmap( 0, sizeof(int) * FRAMES, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)); for(i = 0; i < FRAMES; i++) framesize[i] = start + i * sizeof(int); ? > And use one file... 8-). > Okay, will convert that over...makes for one less point of failure :) > Also: Are you mapping in both the client and the server? Or just the server? > Not quite sure what you mean here...client has: ==== while(ii < FRAMES) { if((fd = open(framestr, O_RDONLY)) < 0) { exit(-1); } if((video[ii] = mmap(0, FRAMESIZE, PROT_READ, MAP_SHARED, fd, 0)) == (caddr_t) -1) { exit(-1); } close(fd); /* Get Video Stream Buffer */ if((fd = open(framestr, O_RDONLY)) < 0) { exit(-1); } if((vsize[ii] = mmap(0, sizeof(int), PROT_READ, MAP_SHARED, fd, 0)) == (caddr_t) -1) { exit(-1); } close(fd); ii++; } ==== I'm using "Advanced Programming in the Unix Environment" by Stevens as my new "bible", and it states that "MAP_SHARED or MAP_PRIVATE must be specified"...unfortunately, his only "example" happens to have two different files MMAP'd, and then he's doing an memcpy() between them :( Is the above incorrect? > > The problem comes up when I try and print out the frame itself, > > using 'printf("%s\n", frame[ii]);'...the value printed out each time > > is exactly the same: > > What is the data in the frame? Maybe that's right? printf("%s", ...) > will stop printing if it hit a <00>... > Binary data, so this may be correct, since the "data" that I'm getting on the opposite end is exactly the same as the data on the server end... Marc G. Fournier scrappy@hub.org Systems Administrator @ hub.org scrappy@freebsd.org