调试ADO.net的一些备忘

1,http://stackoverflow.com/questions/641120/what-exec-sp-reset-connection-shown-in-sql-profiler-means

如果发现用profiler看到的活动里没有RPC:Complete的sp_reset_connection的执行,就要注意了,如果看到spid在不断的上升,说明你在不断的使用新的连接,慢也就算了,还容易把连接池搞爆(ado.net默认使用连接池,上限100个)
2.使用windows系统的performance monitor,加counter, ado.net使用的是.net data provider for SqlServer(or for Oracle), 可以看到如果pooledConnection不断上升,而Reclaimed Connection保持不动,那就很有问题。用上面的铅笔状按钮可以highlight某一个有用的Counter.
3.
下面两个连接很好的解释了如何获取Data Trace的log,都有东西需要下载,其中第二个把内容转了转格式,更好看一些。

转载:TCP handshake

http://www.omnisecu.com/tcpip/tcp-three-way-handshake.htm

TCP Three-way Handshake

ortant; visibility: hidden; z-index: 100000;” >

 

In this ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >lesson, you will learn how two TCP devices synchronize using three way ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >handshake (3 way handshake) and what are the three steps of a TCP three way handshake and how two TCP devices synchronize.

Before the sending device and the receiving device start the ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >exchange of data, both devices need to be synchronized. During the TCP initialization process, the sending device and the receiving device exchange a few control packets for synchronization purposes. This exchange is known as a three-way handshake.

The three-way handshake begins with the initiator sending a TCP segment with the SYN control bit flag set.

TCP allows one side to establish a ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >connection. The other side may either accept the connection or refuse it. If we consider this from application layer point of view, the side that is establishing the connection is the client and the sideortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >waiting for a connection is the ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >server.

TCP identifies two types of OPEN calls:

Active Open. In an Active Open call a device (client process) using TCP takes the active role and initiates theconnection by sending a TCP SYN ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >message to start the connection.

Passive Open A passive OPEN can specify that the device (server process) is waiting for an active OPEN from a specific client. It does not generate any TCP message segment. The server processes listening for the clients are in Passive Open mode.

Transmission Control Protocol TCP Three Way Handshake

TCP Three-way Handshake

Step 1. Device A (Client) sends a TCP segment with SYN = 1, ACK = 0, ISN (ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >Initial Sequence ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >Number) = 2000.

The Active Open device (Device A) sends a segment with the SYN flag set to 1, ACK flag set to 0 and an InitialSequence Number 2000 (For Example), which marks the beginning of the sequence ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >numbers for data that device A will transmit. SYN is short for SYNchronize. SYN flag announces an attempt to open a connection. The first byte transmitted to Device B will have the sequence number ISN+1.

Step 2. Device B (Server) receives Device A’s TCP segment and returns a TCP segment with SYN = 1, ACK = 1, ISN = 5000 (Device B’s Initial Sequence Number), Acknowledgment Number = 2001 (2000 + 1, ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >the next sequence numberDevice B expecting from Device A).

Step 3. Device A sends a TCP segment to Device B that acknowledges receipt of Device B’s ISN, With flags set as SYN = 0, ACK = 1, Sequence number = 2001, Acknowledgment number = 5001 (5000 + 1, the next sequence numberDevice A expecting from Device B)

This handshaking technique is referred to as the Three-way handshake or SYN, SYN-ACK, ACK.

After the three-way handshake, the connection is open and the participant ortant; border-bottom-style: solid !important; border-bottom-color: rgb(254, 109, 76) !important; text-decoration: underline !important; color: rgb(254, 109, 76) !important; background-image: none !important; background-attachment: scroll !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; padding: 0px 0px 1px !important; float: none !important; background-repeat: repeat repeat !important;” >computers start sending data using the sequence and acknowledge numbers.

You have learned what is TCP three way hand shake (3 way handshake), the three steps of a TCP three wayhandshake and how two TCP devices synchronize. Click “Next” to continue.

Explicit implement of Interface

MSDN上提到implicit和Explicit的接口实现的时候。说它的作用只是用于实现多个接口,且这些接口有同名方法时, 明确指明是哪个接口的。

但实际上Explicit还有一个“用处”,当基类是隐式实现接口,而且调用的时候是用接口去调用的时候,子类可以用显式的实现来达到覆盖(new)的效果。换句话说,在作为接口使用时,Interface.fn()比单纯的fn()优先级要高。这不是不同接口间同名方法的差异,而是有接口和无接口的同名方法的差异。往往容易被忽略,尤其是面试的时候。。。