public override uint Send(SNIPacket packet) { lock (this) { try { packet.WriteToStream(_stream); return(TdsEnums.SNI_SUCCESS); } catch (ObjectDisposedException ode) { return(ReportErrorAndReleasePacket(packet, ode)); } catch (IOException ioe) { return(ReportErrorAndReleasePacket(packet, ioe)); } } }
/// <summary> /// Send a packet synchronously /// </summary> /// <param name="packet">SNI packet</param> /// <returns>SNI error code</returns> public override uint Send(SNIPacket packet) { try { packet.WriteToStream(_stream); return(TdsEnums.SNI_SUCCESS); } catch (ObjectDisposedException ode) { return(ReportTcpSNIError(ode)); } catch (SocketException se) { return(ReportTcpSNIError(se)); } catch (IOException ioe) { return(ReportTcpSNIError(ioe)); } }
public override uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = null) { SNIPacket newPacket = packet; _writeTaskFactory.StartNew(() => { try { lock (this) { packet.WriteToStream(_stream); } } catch (Exception e) { SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, e); if (callback != null) { callback(packet, TdsEnums.SNI_ERROR); } else { _sendCallback(packet, TdsEnums.SNI_ERROR); } return; } if (callback != null) { callback(packet, TdsEnums.SNI_SUCCESS); } else { _sendCallback(packet, TdsEnums.SNI_SUCCESS); } }); return(TdsEnums.SNI_SUCCESS_IO_PENDING); }
/// <summary> /// Send a packet asynchronously /// </summary> /// <param name="packet">SNI packet</param> /// <param name="callback">Completion callback</param> /// <returns>SNI error code</returns> public override uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = null) { SNIPacket newPacket = packet; _writeTaskFactory.StartNew(() => { try { lock (this) { packet.WriteToStream(_stream); } } catch (Exception e) { SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.TCP_PROV, 0, 0, e.Message); if (callback != null) { callback(packet, TdsEnums.SNI_ERROR); } else { _sendCallback(packet, TdsEnums.SNI_ERROR); } return; } if (callback != null) { callback(packet, TdsEnums.SNI_SUCCESS); } else { _sendCallback(packet, TdsEnums.SNI_SUCCESS); } }); return(TdsEnums.SNI_SUCCESS_IO_PENDING); }
/// <summary> /// Send a packet synchronously /// </summary> /// <param name="packet">SNI packet</param> /// <returns>SNI error code</returns> public sealed override SNIError Send(SNIPacket packet) { using (_debugLock.Acquire(this)) { try { packet.WriteToStream(_stream); return(null); } catch (ObjectDisposedException ode) { return(new SNIError(ProviderNumber, 0, ode)); } catch (SocketException se) { return(new SNIError(ProviderNumber, 0, se)); } catch (IOException ioe) { return(new SNIError(ProviderNumber, 0, ioe)); } } }