【问题背景】
在loadrunner中利用lrs_receive函数收取一个1712366 bytes大小的数据包时,回放日志中出现如下信息。当时不明白为什么那么多的的8192。
【相关知识】
Gets or sets the size of the receive buffer.
[Visual Basic] Public Property ReceiveBufferSize As Integer [C#] public int ReceiveBufferSize {get; set;} [C++] public: __property int get_ReceiveBufferSize(); public: __property void set_ReceiveBufferSize(int); [JScript] public function get ReceiveBufferSize() : int; public function set ReceiveBufferSize(int);
Property Value
The size of the receive buffer, in bytes. The default value is 8192 bytes.
Remarks
The ReceiveBufferSize property gets or sets the number of bytes that you are expecting to store in the receive buffer for each read operation. This property actually manipulates the network buffer space allocated for receiving incoming data.
Your network buffer should be at least as large as your application buffer to ensure that the desired data will be available when you call the NetworkStream.Read method. Use theReceiveBufferSize property to set this size. If your application will be receiving bulk data, you should pass the Read method a very large application buffer.
If the network buffer is smaller than the amount of data you request in the Read method, you will not be able to retrieve the desired amount of data in one read operation. This incurs the overhead of additional calls to the Read method.
Example
[Visual Basic, C#, C++] The following example sets and gets the receive buffer size.
[Visual Basic] ' Sets the receive buffer size using the ReceiveBufferSize public property. tcpClient.ReceiveBufferSize = 1024 ' Gets the receive buffer size using the ReceiveBufferSize public property. If tcpClient.ReceiveBufferSize = 1024 Then Console.WriteLine(("The receive buffer was successfully set to " + tcpClient.ReceiveBufferSize.ToString())) End If [C#] // Sets the receive buffer size using the ReceiveBufferSize public property. tcpClient.ReceiveBufferSize = 1024; // Gets the receive buffer size using the ReceiveBufferSize public property. if (tcpClient.ReceiveBufferSize == 1024) Console.WriteLine ("The receive buffer was successfully set to " + tcpClient.ReceiveBufferSize.ToString ()); [C++] // sets the receive buffer size using the ReceiveBufferSize public property. tcpClient->ReceiveBufferSize = 1024; // gets the receive buffer size using the ReceiveBufferSize public property. if (tcpClient->ReceiveBufferSize == 1024) Console::WriteLine(S"The receive buffer was successfully set to {0}", __box(tcpClient->ReceiveBufferSize));
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework