Dart.Snmp Namespace > MessageBase Class : EncodedMessage Property |
Public ReadOnly Property EncodedMessage As Byte()
Dim instance As MessageBase Dim value() As Byte value = instance.EncodedMessage
public byte[] EncodedMessage {get;}
public: __property byte[]* get_EncodedMessage();
public: property array<byte>^ EncodedMessage { array<byte>^ get(); }
For messages received asynchronously, this property contains a copy of the original encoded packet. Set when Encode is used.
private void button1_Click(object sender, EventArgs e) { //Create Get Request GetMessage request = new GetMessage(); request.Variables.Add(manager1.Mib.CreateVariable(NodeName.sysDescr)); //Send request and get response SnmpSocket managerSocket = new SnmpSocket(manager1); ResponseMessage response = managerSocket.GetResponse(request, myAgentAddress); //Log the request and response PDUs FileStream file = new FileStream("log.txt", FileMode.Append, FileAccess.Write); string requestLabel = "\r\nRequest:\r\n"; string responseLabel = "\r\nResponse:\r\n"; file.Write(System.Text.Encoding.Default.GetBytes(requestLabel), 0, requestLabel.Length); file.Write(request.EncodedMessage, 0, request.EncodedMessage.Length); file.Write(System.Text.Encoding.Default.GetBytes(responseLabel), 0, responseLabel.Length); file.Write(response.EncodedMessage, 0, response.EncodedMessage.Length); file.Close(); }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) 'Create Get Request Dim request As New GetMessage() request.Variables.Add(manager1.Mib.CreateVariable(NodeName.sysDescr)) 'Send request and get response Dim managerSocket As New SnmpSocket(manager1) Dim response As ResponseMessage = managerSocket.GetResponse(request, myAgentAddress) 'Log the request and response PDUs Dim file As New FileStream("log.txt", FileMode.Append, FileAccess.Write) Dim requestLabel As String = vbCrLf & "Request:" & vbCrLf Dim responseLabel As String = vbCrLf & "Response:" & vbCrLf file.Write(System.Text.Encoding.Default.GetBytes(requestLabel), 0, requestLabel.Length) file.Write(request.EncodedMessage, 0, request.EncodedMessage.Length) file.Write(System.Text.Encoding.Default.GetBytes(responseLabel), 0, responseLabel.Length) file.Write(response.EncodedMessage, 0, response.EncodedMessage.Length) file.Close() End Sub