Đang chuẩn bị liên kết để tải về tài liệu:
Programming C#, 2nd Edition

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Trong một số cách, cách tiếp cận để tuần tự thể hiện trong Ví dụ 21-15 là rất lãng phí. Bởi vì bạn có thể tính toán các nội dung của mảng số bắt đầu và kết thúc của nó, có thực sự là không có lý do để lưu trữ các phần tử của nó vào đĩa. Mặc dù các hoạt động có thể được không tốn kém với một mảng nhỏ, nó có thể trở nên tốn kém với một trong rất lớn. | Programming C 2nd Edition if bytesRead 0 write it out to the client networkStream.BeginWrite buffer 0 bytesRead callbackWrite null If OnFileCompletedRead was called and no bytes were read this signifies that the entire file has been sent. The server reacts by closing the NetworkStream and socket thus letting the client know that the transaction is complete networkStream.Close socket.Close networkStream null socket null When the network write completes the OnWriteComplete method is called and this kicks off another read from the file private void OnWriteComplete IAsyncResult ar networkStream.EndWrite ar Console.WriteLine Write complete inputStream.BeginRead buffer holds the results 0 offset buffer.Length BufferSize myFileCallBack call back delegate null local state object The cycle begins again with another read of the file and the cycle continues until the file has been completely read and transmitted to the client. The client code simply writes a filename to the network stream to kick off the file read string message @ C test source AskTim.txt System.IO.StreamWriter writer new System.IO.StreamWriter streamToServer writer.Write message writer.Flush The client then begins a loop reading from the network stream until no bytes are sent by the server. When the server is done the network stream is closed. Start by initializing a Boolean value to false and creating a buffer to hold the bytes sent by the server bool fQuit false while fQuit char buffer new char BufferSize You are now ready to create a new StreamReader from the NetworkStream member variable streamToServer System.IO.StreamReader reader new System.IO.StreamReader streamToServer 526 Programming C 2nd Edition The call to Read takes three parameters the buffer the offset at which to begin reading and the size of the buffer int bytesRead reader.Read buffer 0 Buffersize Check to see if the Read returned any bytes if not you are done and you can set the Boolean value fQuit to true causing the loop to terminate if .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.