[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgDbClient.cs,1.6
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-09-01 11:13:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv24269 Modified Files: PgDbClient.cs Log Message: Removed socket and networkStream fields that now are handled by the TLS implementation. Index: PgDbClient.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PgDbClient.cs 22 Aug 2003 15:53:31 -0000 1.6 --- PgDbClient.cs 1 Sep 2003 11:13:25 -0000 1.7 *************** *** 25,30 **** using System.Text; ! using PgSqlClient.Security.TLS; ! using PgSqlClient.Security.TLS.Alerts; namespace PostgreSql.Data.NPgClient --- 25,30 ---- using System.Text; ! using System.Security.Tls; ! using System.Security.Tls.Alerts; namespace PostgreSql.Data.NPgClient *************** *** 51,56 **** private int secretKey; private Hashtable parameterStatus; - private Socket socket; - private NetworkStream networkStream; private TlsWriter send; private TlsReader receive; --- 51,54 ---- *************** *** 97,105 **** } - public Socket Socket - { - get { return socket; } - } - public TlsReader Receive { --- 95,98 ---- *************** *** 145,151 **** lock (this) { ! session = new TlsSession(new TlsSessionSettings(TlsProtocol.Tls1)); ! ! initializeSocket(); if (settings.SSL) --- 138,145 ---- lock (this) { ! TlsSessionSettings tlsSettings = new TlsSessionSettings(TlsProtocol.Tls1, settings.ServerName, settings.ServerPort); ! session = new TlsSession(tlsSettings); ! send = session.GetWriter(); ! receive = session.GetReader(); if (settings.SSL) *************** *** 164,171 **** { // If the exception is fatal close connection ! if (ex.AlertLevel == TlsAlertLevel.Fatal) ! { ! this.Detach(); ! } throw new PgClientException(ex.Message); } --- 158,163 ---- { // If the exception is fatal close connection ! session.EndSession(); ! throw new PgClientException(ex.Message); } *************** *** 200,204 **** catch (PgClientException ex) { ! this.Detach(); throw ex; } --- 192,196 ---- catch (PgClientException ex) { ! session.EndSession(); throw ex; } *************** *** 213,224 **** SendData(packet.GetPacketBytes(PgFrontEndCodes.TERMINATE)); ! // if it's an SSL connection end session ! if (settings.SSL) ! { ! session.EndSession(); ! } ! ! // Close socket and streams ! this.Detach(); } catch (PgClientException ex) --- 205,210 ---- SendData(packet.GetPacketBytes(PgFrontEndCodes.TERMINATE)); ! // End session ! session.EndSession(); } catch (PgClientException ex) *************** *** 228,250 **** } - public void Detach() - { - // Close socket and streams - receive.Close(); - send.Close(); - socket.Close(); - } - internal void SendData(byte[] data) { ! if (settings.SSL) ! { ! send.WriteRecord(data); ! } ! else ! { ! send.Write(data); ! } ! send.Flush(); } --- 214,220 ---- } internal void SendData(byte[] data) { ! send.Write(data); send.Flush(); } *************** *** 773,798 **** { return new PgStatement(this, parseName, portalName, stmtText); - } - - #endregion - - #region PRIVATE_METHODS - - private void initializeSocket() - { - IPAddress hostadd = Dns.Resolve(settings.ServerName).AddressList[0]; - IPEndPoint EPhost = new IPEndPoint(hostadd, settings.ServerPort); - - socket = new Socket(AddressFamily.InterNetwork, - SocketType.Stream, - ProtocolType.IP); - - // Make the socket to connect to the Server - socket.Connect(EPhost); - networkStream = new NetworkStream(socket, true); - - // Create streams for read/write operations - send = session.GetWriter(networkStream); - receive = session.GetReader(networkStream); } --- 743,746 ---- |