Assignment
• Server sends a specific file to every client that
connects to it.
• The file name should be sent with the file data in
the same byte array.
• The first 4 bytes should represent an integer that
represents the length of the file name.
• If the file name is “file.txt” and has “abcdefgh” as
content then the first 4 bytes should be the binary
representation of the number “8” (length of “file.txt”)
Assignment
• Then the next 8 bytes should represent the 8
characters of the file name “file.txt”
– byte #4 -> ascii of ‘f’
– byte #5-> ascii of ‘i’
– ….
0 0 0 8 f i l e . t x t a b c d e f g h
• The rest of the bytes should be the file contents.
• You cannot use the “Socket.SendFile” method.
• Hint: use BitConverter.GetBytes to convert int to
byte array.
• Hint: use CopyTo method in the array to copy
array into another at specific indices.
Assignment Delivery Rules
• Console Application for each of the Server and
client.
• We may test the server using our own client,
so the server must send with the specified
format.
• At the application startup, write your name
and section and department exactly as in the
screenshot.
Assignment Delivery Rules
• The server should listen for connection on IP
address: 127.0.0.1 and Port 8000.
• The file name will be passed to the server as a
command line argument.
• You can set the argument in the debug time
by opening the project properties and setting
the command line arguments in the Debug
tab.
Assignment Delivery Rules
• Running the exe using cmd.
Testing the Client/Server apps
• Build each project
• Right click on the “server” project -> Debug -
>Start new instance.
• Right click on the “Client” project-> Debug -
>Start new instance.
References
• C# Network Programming, by Richard
Blum ISBN:0782141765 Sybex © 2003.
• Stanford CS244A course handouts.