1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 6 namespace System.Data.SqlClient.SNI 7 { 8 /// <summary> 9 /// SNI connection handle 10 /// </summary> 11 internal abstract class SNIHandle 12 { 13 /// <summary> 14 /// Dispose class 15 /// </summary> Dispose()16 public abstract void Dispose(); 17 18 /// <summary> 19 /// Set async callbacks 20 /// </summary> 21 /// <param name="receiveCallback">Receive callback</param> 22 /// <param name="sendCallback">Send callback</param> SetAsyncCallbacks(SNIAsyncCallback receiveCallback, SNIAsyncCallback sendCallback)23 public abstract void SetAsyncCallbacks(SNIAsyncCallback receiveCallback, SNIAsyncCallback sendCallback); 24 25 /// <summary> 26 /// Set buffer size 27 /// </summary> 28 /// <param name="bufferSize">Buffer size</param> SetBufferSize(int bufferSize)29 public abstract void SetBufferSize(int bufferSize); 30 31 /// <summary> 32 /// Send a packet synchronously 33 /// </summary> 34 /// <param name="packet">SNI packet</param> 35 /// <returns>SNI error code</returns> Send(SNIPacket packet)36 public abstract uint Send(SNIPacket packet); 37 38 /// <summary> 39 /// Send a packet asynchronously 40 /// </summary> 41 /// <param name="packet">SNI packet</param> 42 /// <param name="callback">Completion callback</param> 43 /// <returns>SNI error code</returns> SendAsync(SNIPacket packet, SNIAsyncCallback callback = null)44 public abstract uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = null); 45 46 /// <summary> 47 /// Receive a packet synchronously 48 /// </summary> 49 /// <param name="packet">SNI packet</param> 50 /// <param name="timeoutInMilliseconds">Timeout in Milliseconds</param> 51 /// <returns>SNI error code</returns> Receive(out SNIPacket packet, int timeoutInMilliseconds)52 public abstract uint Receive(out SNIPacket packet, int timeoutInMilliseconds); 53 54 /// <summary> 55 /// Receive a packet asynchronously 56 /// </summary> 57 /// <param name="packet">SNI packet</param> 58 /// <returns>SNI error code</returns> ReceiveAsync(ref SNIPacket packet)59 public abstract uint ReceiveAsync(ref SNIPacket packet); 60 61 /// <summary> 62 /// Enable SSL 63 /// </summary> EnableSsl(uint options)64 public abstract uint EnableSsl(uint options); 65 66 /// <summary> 67 /// Disable SSL 68 /// </summary> DisableSsl()69 public abstract void DisableSsl(); 70 71 /// <summary> 72 /// Check connection status 73 /// </summary> 74 /// <returns>SNI error code</returns> CheckConnection()75 public abstract uint CheckConnection(); 76 77 /// <summary> 78 /// Last handle status 79 /// </summary> 80 public abstract uint Status { get; } 81 82 /// <summary> 83 /// Connection ID 84 /// </summary> 85 public abstract Guid ConnectionId { get; } 86 87 #if DEBUG 88 /// <summary> 89 /// Test handle for killing underlying connection 90 /// </summary> KillConnection()91 public abstract void KillConnection(); 92 #endif 93 } 94 } 95