Homework 4: Sockets and Network File Systems

Total Page:16

File Type:pdf, Size:1020Kb

Homework 4: Sockets and Network File Systems

Homework 4: Sockets and Network File Systems In this homework you will use sockets to emulate a simple network file system. The remote machine controls a file system. However, a user on any machine on the local network can access the file system, via your simple network file system software. Server The server is on the machine controlling the file system. The server supports the following function:  Server_Read: Parameters include the filename and the location in the file to read from. The server returns 2k of data starting at the requested address, as well as the total number of bytes read (0..2k). Client The client is on a machine that does not have direct access to the requested files (supposedly…) Create a new class MyFile, which supports the following methods:  open(filename);  String read(number_of_bytes);  close(); The open method stores the filename for future calls, and initializes a read file pointer to point to the beginning of the file. No call to the server occurs. The read method sends a Server_Read message to the server, listing the filename and the location in the file to read from. The server returns 2k of data starting at the requested address. The client logic must parse out the requested data to return to the user application, then increment the file pointer by the number of bytes read. Future reads are from the cached buffer, until all data in the cache is read – and then a new read from the server is requested. The close method clears any read buffer. Note: This implementation is extremely simple compared to commercial software. In commercial software:  the open minimally must verify that the file exists and permissions are compatible,  the write also occurs in large chunks of data, and  the reads and writes have timeout values, to ensure data does not get stale. User Program Generate a user program that creates a MyFile instance and reads and prints the file to the screen or copies it to another file. Test your program to ensure that the user program can perform reads of any size (1 byte to 2k bytes). The cache buffering should be transparent to the user program. Assignment Deliverables Please turn in your code in paper format as well as by electronic submission. No lab paper is required. The assignment is due at the time of the final exam.

Recommended publications