[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgDbClient.cs,1.4
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2004-02-15 00:24:45
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv934 Modified Files: PgDbClient.cs PgStatement.cs Log Message: 2004-02-15 Carlos Guzmán Álvarez <car...@te...> * source/NPgClient/PgDbClient.cs: * source/NPgClient/PgStatement.cs: - Simplify packet write. Index: PgDbClient.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** PgDbClient.cs 9 Feb 2004 14:20:45 -0000 1.41 --- PgDbClient.cs 15 Feb 2004 00:17:52 -0000 1.42 *************** *** 145,185 **** PgDbClient.InitializeCharSets(); ! initializeSocket(); lock (this) { ! if (settings.SSL) { // Send SSL request message ! SSLRequest(); ! if (settings.SSL) { ! sslStream = new SslClientStream( ! networkStream, ! settings.ServerName, true, Mono.Security.Protocol.Tls.SecurityProtocolType.Default); ! receive = new BinaryReader(sslStream); ! send = new BinaryWriter(sslStream); } } // Send Startup message ! PgOutputPacket packet = new PgOutputPacket(settings.Encoding); packet.WriteInt(PgCodes.PROTOCOL_VERSION3); packet.WriteString("user"); ! packet.WriteString(settings.UserName); ! if (settings.Database != null && settings.Database.Length > 0) { packet.WriteString("database"); ! packet.WriteString(settings.Database); } packet.Write((byte)0); // Terminator // Handshake protocol will be negotiated here if the connection is using SSL/TLS ! SendData(packet.GetSimplePacketBytes()); PgResponsePacket response = new PgResponsePacket(); --- 145,186 ---- PgDbClient.InitializeCharSets(); ! this.initializeSocket(); lock (this) { ! if (this.settings.SSL) { // Send SSL request message ! this.SSLRequest(); ! if (this.settings.SSL) { ! this.sslStream = new SslClientStream( ! this.networkStream, ! this.settings.ServerName, true, Mono.Security.Protocol.Tls.SecurityProtocolType.Default); ! this.receive = new BinaryReader(this.sslStream); ! this.send = new BinaryWriter(this.sslStream); } } // Send Startup message ! PgOutputPacket packet = new PgOutputPacket(this.settings.Encoding); packet.WriteInt(PgCodes.PROTOCOL_VERSION3); packet.WriteString("user"); ! packet.WriteString(this.settings.UserName); ! if (settings.Database != null && ! this.settings.Database.Length > 0) { packet.WriteString("database"); ! packet.WriteString(this.settings.Database); } packet.Write((byte)0); // Terminator // Handshake protocol will be negotiated here if the connection is using SSL/TLS ! this.SendSimplePacket(packet); PgResponsePacket response = new PgResponsePacket(); *************** *** 188,193 **** while (response.Message != PgBackendCodes.READY_FOR_QUERY) { ! response = ReceiveResponsePacket(); ! processResponsePacket(response); } } --- 189,194 ---- while (response.Message != PgBackendCodes.READY_FOR_QUERY) { ! response = this.ReceiveResponsePacket(); ! this.processResponsePacket(response); } } *************** *** 195,204 **** catch (IOException ex) { ! detach(); throw new PgClientException(ex.Message); } catch (PgClientException ex) { ! detach(); throw ex; } --- 196,205 ---- catch (IOException ex) { ! this.detach(); throw new PgClientException(ex.Message); } catch (PgClientException ex) { ! this.detach(); throw ex; } *************** *** 211,217 **** // Send packet to the server PgOutputPacket packet = new PgOutputPacket(); ! SendData(packet.GetPacketBytes(PgFrontEndCodes.TERMINATE)); ! detach(); } catch (IOException ex) --- 212,218 ---- // Send packet to the server PgOutputPacket packet = new PgOutputPacket(); ! this.SendPacket(packet, PgFrontEndCodes.TERMINATE); ! this.detach(); } catch (IOException ex) *************** *** 225,233 **** } ! internal void SendData(byte[] data) { try { ! send.Write(data); } catch (IOException ex) --- 226,250 ---- } ! #endregion ! ! #region Send Methods ! ! internal void SendPacket(PgOutputPacket packet, char type) { try { ! this.send.Write(packet.GetPacketBytes(type)); ! } ! catch (IOException ex) ! { ! throw ex; ! } ! } ! ! internal void SendSimplePacket(PgOutputPacket packet) ! { ! try ! { ! this.send.Write(packet.GetSimplePacketBytes()); } catch (IOException ex) *************** *** 405,409 **** // Send the packet to the server ! SendData(outPacket.GetPacketBytes(PgFrontEndCodes.PASSWORD_MESSAGE)); } --- 422,426 ---- // Send the packet to the server ! this.SendPacket(outPacket, PgFrontEndCodes.PASSWORD_MESSAGE); } *************** *** 552,556 **** // Send packet to the server ! SendData(packet.GetPacketBytes(PgFrontEndCodes.FLUSH)); } catch (Exception ex) --- 569,573 ---- // Send packet to the server ! this.SendPacket(packet, PgFrontEndCodes.FLUSH); } catch (Exception ex) *************** *** 570,574 **** // Send packet to the server ! SendData(packet.GetPacketBytes(PgFrontEndCodes.SYNC)); // Receive response --- 587,591 ---- // Send packet to the server ! this.SendPacket(packet, PgFrontEndCodes.SYNC); // Receive response *************** *** 608,612 **** // Send packet to the server ! SendData(packet.GetSimplePacketBytes()); } catch (Exception ex) --- 625,629 ---- // Send packet to the server ! this.SendSimplePacket(packet); } catch (Exception ex) *************** *** 621,625 **** lock (this) { ! settings.SSL = false; try --- 638,642 ---- lock (this) { ! this.settings.SSL = false; try *************** *** 630,634 **** // Send packet to the server ! SendData(packet.GetSimplePacketBytes()); // Receive server response --- 647,651 ---- // Send packet to the server ! this.SendSimplePacket(packet); // Receive server response *************** *** 638,646 **** { case 'S': ! settings.SSL = true; break; default: ! settings.SSL = false; break; } --- 655,663 ---- { case 'S': ! this.settings.SSL = true; break; default: ! this.settings.SSL = false; break; } Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PgStatement.cs 9 Feb 2004 14:20:45 -0000 1.22 --- PgStatement.cs 15 Feb 2004 00:17:53 -0000 1.23 *************** *** 202,207 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.PARSE)); ! // Update status this.status = PgStatementStatus.Parsed; --- 202,207 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.PARSE); ! // Update status this.status = PgStatementStatus.Parsed; *************** *** 241,245 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.DESCRIBE)); // Flush pending messages --- 241,245 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.DESCRIBE); // Flush pending messages *************** *** 303,307 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.BIND)); // Update status --- 303,307 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.BIND); // Update status *************** *** 330,334 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.EXECUTE)); // Flush pending messages --- 330,334 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.EXECUTE); // Flush pending messages *************** *** 406,410 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.FUNCTION_CALL)); // Receive response --- 406,410 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.FUNCTION_CALL); // Receive response *************** *** 442,446 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.QUERY)); // Update Status --- 442,446 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.QUERY); // Update Status *************** *** 551,555 **** // Send packet to the server ! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.CLOSE)); // Sync server and client --- 551,555 ---- // Send packet to the server ! db.SendPacket(packet, PgFrontEndCodes.CLOSE); // Sync server and client |