Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The function handleClient(void vPtr) is run in its own thread. It receives vPtr which points an integer file descriptor for talking to the client. It

image text in transcribed

The function handleClient(void vPtr) is run in its own thread. It receives vPtr which points an integer file descriptor for talking to the client. It should: 6. Sockets and Files Finish the server function below which is told A. Cast vPtr to type int and set clientFd to the integer passed o a minimum file size o a maximum file size freet) C. Get the value of min from the client. Then, change it from network It then iterates over the entries in the current directory (named ) and returns the endian to host (this computer) endian. D. Get the value of nax from the client. Then, change it from network endian to host (this computer) endian. E. Set dirPtr to read from the current directory-.- F. In a loop, set entryptr equal to the address of the next entry read from for every file (not directory or anything else) whose file length is between the minimum and maximum. The server tells the client it has no more by G. Fill statbutter full of the meta-data about the current entry. sending: dirPtr H. Look for only those entries that are files of the desired size (done for o o as the file length you) I. Set fitelen_net and fiteamelen net to the lengths of the file and of the . the filename length filename in network endian! All integers (min, max, file lengths and filename lengths) are sent ir J.Send fiteten net, fiteNaneLen net and the first fiteNaneLen bytes of the ir network endianness! Example If a directory has the following files: filename back to the client. K. Close dirptr L. Set fileLen_net and fiteSameLen_net both to o in network endian! M. Send iteten net and teNanelen netback to the client N. Close ctientrd (done for you) Do not worry about error checking! idefine void handlectient (void vPtr) total 112 ar-. instructor instructor 738B Nov 14 14:23 client M-r-r-1 instructor instructor 2117 Nov 14 14:23 ctient.c 256 . instructor instructor 13760 Nov 14 14:17 server rv-r-r-,1 instructor instructer 2980 Nov 14 14:17 server. M-m.r..1 instructor instructor 14406 Nov 14 13138 20178-1Fat Cc374 Finat.htnt wr. 1 nstructor instructor 14405 Nov 14 07:45 20178-1Fal CSC374 Final h Char bufferBuFFER LEN -M-H-instructor instructer 608 Nov 14 07:45 bad.c 0: (A) change that unsigned int nin unsigned int nax x.. instructor instructor 4999 Nov 34 07:45 bad W-FN-s.1 instructor instructor 620 Nov 14 07:31 bad.C w-w-..-. 2 instructor inst ructor 696 Nov 14 07:03 optinizeme.c xn--1 instructor instructor 7491 Nov 14 06:49 cratyIcecrean w-w-.1 instructor instructor 2484 Nov 14 06:49 crazyIceCrea w-w-. instructor inst ructor 271 Nov 14 06:29 nenory. M-m-r--1 instructor instructor 1702 Aug 16 11:52 etient.c- w-M-F1 instructor inst ructor 2279 Aug 16 11:48 server.c w-m.r.l instructor inst ructor 439 Aug 16 11:46 header.h I (C) and I ask for every file between length 500 and 1000 fiteLen net: Machine nane (e-g. localhost)7 localhost Port nunber? 2000 unsigned int Please enter a ninisun fitesine: 50 Please enter a naxinun itesize: 1000 struct stat struct dirent statBuffer: entryPtr dirPtr = NLULL; // (E).. Change that 0 then the program returns these 3 files: bad.- 620 white (entryPtr(F) NULL optinizec 696 Protocol: ir client S ISREGIstatBuffer.st node) & (statBuffer.st sizemin) (statBuffer.st sizemax) 1500 (network endian) 100 (network endian) fileNaneLen filelen_net fiteNaneLen net 11(11) strien(entryPtr->d nane) 620 (network endian) 1 (the length of bedt- 1 (network endian) 1 (the tength of the string "bad.- I (do not send the quotes or the "ve char) T (k) I 608 (network endian) (the Length of bad.c) I (L) 1 5 (network endian) 1 (the tength of the string "bad.c I (N) close(clientFd): return(NULL) (do not send the quotes or the .V0' char) 696 (network endian) 1 (the Length of optinizeMec (network endian) (the length of the string "eptinizeMec I (do not send the quotes or the char) 0 (network endian)(seans "end of files) Inetvork endantseans end of fites") The function handleClient(void vPtr) is run in its own thread. It receives vPtr which points an integer file descriptor for talking to the client. It should: 6. Sockets and Files Finish the server function below which is told A. Cast vPtr to type int and set clientFd to the integer passed o a minimum file size o a maximum file size freet) C. Get the value of min from the client. Then, change it from network It then iterates over the entries in the current directory (named ) and returns the endian to host (this computer) endian. D. Get the value of nax from the client. Then, change it from network endian to host (this computer) endian. E. Set dirPtr to read from the current directory-.- F. In a loop, set entryptr equal to the address of the next entry read from for every file (not directory or anything else) whose file length is between the minimum and maximum. The server tells the client it has no more by G. Fill statbutter full of the meta-data about the current entry. sending: dirPtr H. Look for only those entries that are files of the desired size (done for o o as the file length you) I. Set fitelen_net and fiteamelen net to the lengths of the file and of the . the filename length filename in network endian! All integers (min, max, file lengths and filename lengths) are sent ir J.Send fiteten net, fiteNaneLen net and the first fiteNaneLen bytes of the ir network endianness! Example If a directory has the following files: filename back to the client. K. Close dirptr L. Set fileLen_net and fiteSameLen_net both to o in network endian! M. Send iteten net and teNanelen netback to the client N. Close ctientrd (done for you) Do not worry about error checking! idefine void handlectient (void vPtr) total 112 ar-. instructor instructor 738B Nov 14 14:23 client M-r-r-1 instructor instructor 2117 Nov 14 14:23 ctient.c 256 . instructor instructor 13760 Nov 14 14:17 server rv-r-r-,1 instructor instructer 2980 Nov 14 14:17 server. M-m.r..1 instructor instructor 14406 Nov 14 13138 20178-1Fat Cc374 Finat.htnt wr. 1 nstructor instructor 14405 Nov 14 07:45 20178-1Fal CSC374 Final h Char bufferBuFFER LEN -M-H-instructor instructer 608 Nov 14 07:45 bad.c 0: (A) change that unsigned int nin unsigned int nax x.. instructor instructor 4999 Nov 34 07:45 bad W-FN-s.1 instructor instructor 620 Nov 14 07:31 bad.C w-w-..-. 2 instructor inst ructor 696 Nov 14 07:03 optinizeme.c xn--1 instructor instructor 7491 Nov 14 06:49 cratyIcecrean w-w-.1 instructor instructor 2484 Nov 14 06:49 crazyIceCrea w-w-. instructor inst ructor 271 Nov 14 06:29 nenory. M-m-r--1 instructor instructor 1702 Aug 16 11:52 etient.c- w-M-F1 instructor inst ructor 2279 Aug 16 11:48 server.c w-m.r.l instructor inst ructor 439 Aug 16 11:46 header.h I (C) and I ask for every file between length 500 and 1000 fiteLen net: Machine nane (e-g. localhost)7 localhost Port nunber? 2000 unsigned int Please enter a ninisun fitesine: 50 Please enter a naxinun itesize: 1000 struct stat struct dirent statBuffer: entryPtr dirPtr = NLULL; // (E).. Change that 0 then the program returns these 3 files: bad.- 620 white (entryPtr(F) NULL optinizec 696 Protocol: ir client S ISREGIstatBuffer.st node) & (statBuffer.st sizemin) (statBuffer.st sizemax) 1500 (network endian) 100 (network endian) fileNaneLen filelen_net fiteNaneLen net 11(11) strien(entryPtr->d nane) 620 (network endian) 1 (the length of bedt- 1 (network endian) 1 (the tength of the string "bad.- I (do not send the quotes or the "ve char) T (k) I 608 (network endian) (the Length of bad.c) I (L) 1 5 (network endian) 1 (the tength of the string "bad.c I (N) close(clientFd): return(NULL) (do not send the quotes or the .V0' char) 696 (network endian) 1 (the Length of optinizeMec (network endian) (the length of the string "eptinizeMec I (do not send the quotes or the char) 0 (network endian)(seans "end of files) Inetvork endantseans end of fites")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions