1. Network Sockets
Consider two pseudo-code snippets illustrating file transfer mechanisms between a client and a server.
Pseudo-code 1
Client:
file = openFile("localFile.txt")
chunk = readFileChunk(file)
while (chunk is not empty)
transmitData(chunk)
chunk = readFileChunk(file)
endWhile
closeFile(file)
Server:
file = createFile("receivedFile.txt")
while (dataAvailable())
chunk = receiveData()
writeFileChunk(file, chunk)
endWhile
closeFile(file)
Pseudo-code 2
Client:
file = openFile("localFile.txt")
data = readEntireFile(file)
transmitData(data)
closeFile(file)
Server:
data = receiveDataUntilComplete()
file = createFile("receivedFileComplete.txt")
writeEntireFile(file, data)
closeFile(file)
Which of the following statement(s) are true?
Pick ONE OR MORE options.
This question compares chunked file transfer versus whole-file transfer between a client and a server. Pseudo-code 1 streams data in chunks, which is more memory-efficient and suitable for large files or unstable connections. Pseudo-code 2 reads the entire file into memory before sending, which is simpler but less scalable. The key idea is to recognize buffering, transmission completion, and whether the server needs protocol support to detect the end of data.