1 // created on 11/6/2002 at 11:53
3 // Npgsql.NpgsqlBackEndKeyData.cs
6 // Francisco Jr. (fxjrlists@yahoo.com.br)
8 // Copyright (C) 2002 The Npgsql Development Team
9 // npgsql-general@gborg.postgresql.org
10 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2.1 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 /// This class represents a BackEndKeyData message received
39 internal sealed class NpgsqlBackEndKeyData
41 // Logging related values
42 private static readonly String CLASSNAME = "NpgsqlBackEndKeyData";
44 private Int32 _processId;
45 private Int32 _secretKey;
47 private ProtocolVersion _protocolVersion;
49 public NpgsqlBackEndKeyData(ProtocolVersion protocolVersion)
51 _protocolVersion = protocolVersion;
57 public void ReadFromStream(Stream inputStream)
59 NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME);
61 Byte[] inputBuffer = new Byte[8];
63 // Read the BackendKeyData message contents. Two Int32 integers = 8 Bytes.
64 // For protocol version 3.0 they are three integers. The first one is just the size of message
66 if (_protocolVersion >= ProtocolVersion.Version3)
67 inputStream.Read(inputBuffer, 0, 4);
69 inputStream.Read(inputBuffer, 0, 8);
70 _processId = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(inputBuffer, 0));
71 _secretKey = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(inputBuffer, 4));
75 public Int32 ProcessID
79 NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "ProcessID");
84 public Int32 SecretKey
88 NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "SecretKey");