Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1.  
  2. CS360 Lab Assignment #3 : File Operations across Networks
  3.  
  4. WORK IN 2-PERSON TEAMS
  5. DUE & DENO : to be posted
  6.  
  7. A. OBJECTIVES:
  8. Network Programming using TCP.
  9. Unix system calls for file operations.
  10.  
  11. B. TCP/IP Program:
  12. Per LAB4 Pre-work.
  13.  
  14. C. REQUIREMENTS:
  15. Modify the server/client programs in the pre-lab to do the following:
  16.  
  17. Client : input a command:
  18. ----------------
  19. pwd
  20. ls [pathname]
  21. cd pathname
  22. mkdir pathname
  23. rmdir pathname
  24. rm pathname (rm pathname)
  25. get pathname (cp pathname to client side)
  26. put pathname (cp pathanme to server side)
  27. quit (Client exits)
  28. -----------------
  29. send command to Server.
  30. receive reply AND results from Server. Display the results
  31.  
  32. Also,implement the (local) commands
  33. lcat lpwd, lls, lcd, lmkdir. lrmdir, lrm
  34. which the Client executes LOCALLY.
  35.  
  36. Server:
  37. get a command from Client;
  38. perform the command;
  39. send reply to Client;
  40.  
  41. *************************************************************
  42. * OUTPUTS REQUIREMENTS: CONSULT THE POSTED SAMPLE SOLUTION *
  43. *************************************************************
  44.  
  45. C. HELP Hints:
  46.  
  47. (1). Make each command a fixed-length string, e.g. of MAX=256 bytes.
  48. REASON: a TCP socket contains a "stream" of data. Each read operation
  49. reads whatever is available in the socket. Using fixed-length
  50. items simplifies reading individual command strings.
  51.  
  52. (2). Assume get filname:
  53.  
  54. CLIENT SERVER
  55. ------------------------------- -------------------------------
  56. send request (get filename) ====> stat filename to get type AND SIZE
  57. wait for reply <=== send SIZE=xxxx or BAD
  58. if (BAD): next input; if (BAD): next command
  59. ====================================================================
  60. count = 0;
  61. open filename for WRITE open filename for READ
  62. while(count < SIZE){ while(n=read(fd, buf, MAX)){
  63. n = read(socket,buf,MAX); <===== send n bytes from buf
  64. count += n;
  65. write n bytes to file;
  66. } }
  67. close file; close file;
  68. /*******************************************************************/
  69.  
  70. (3). You figure out the algorithm for put filname
  71.  
  72.  
  73. Sample Solutions
  74. samples/LAB3/ : server and client
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement