本文整理汇总了C#中SocketShutdown类的典型用法代码示例。如果您正苦于以下问题:C# SocketShutdown类的具体用法?C# SocketShutdown怎么用?C# SocketShutdown使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketShutdown类属于命名空间,在下文中一共展示了SocketShutdown类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalShutdown
// don't change for default, otherwise breaking change
// this version does not throw.
internal void InternalShutdown (SocketShutdown how)
{
if (!is_connected || is_disposed)
return;
int error;
Shutdown_internal (safe_handle, how, out error);
}
示例2: InternalShutdown
// don't change for default, otherwise breaking change
// this version does not throw.
internal void InternalShutdown (SocketShutdown how)
{
if (!connected || disposed)
return;
int error;
Shutdown_internal (socket, how, out error);
}
示例3: InternalShutdown
// don't change for default, otherwise breaking change
// this version does not throw.
internal void InternalShutdown (SocketShutdown how)
{
if (!is_connected || CleanedUp)
return;
int error;
Shutdown_internal (m_Handle, how, out error);
}
示例4: Shutdown
internal static Error Shutdown(SafeHandle socket, SocketShutdown how)
{
bool release = false;
try
{
socket.DangerousAddRef(ref release);
return DangerousShutdown((int)socket.DangerousGetHandle(), how);
}
finally
{
if (release)
{
socket.DangerousRelease();
}
}
}
示例5: Shutdown_internal
internal extern static void Shutdown_internal (IntPtr socket, SocketShutdown how, out int error);
示例6: Shutdown
public void Shutdown (SocketShutdown how)
{
ThrowIfDisposedAndClosed ();
if (!is_connected)
throw new SocketException (10057); // Not connected
int error;
Shutdown_internal (safe_handle, how, out error);
if (error != 0)
throw new SocketException (error);
}
示例7: Shutdown
// Disables sends and receives on a socket.
public void Shutdown(SocketShutdown how)
{
if (s_loggingEnabled)
{
Logging.Enter(Logging.Sockets, this, "Shutdown", how);
}
if (CleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
GlobalLog.Print("Socket#" + Logging.HashString(this) + "::Shutdown() how:" + how.ToString());
// This can throw ObjectDisposedException.
SocketError errorCode = SocketPal.Shutdown(_handle, _isConnected, _isDisconnected, how);
GlobalLog.Print("Socket#" + Logging.HashString(this) + "::Shutdown() Interop.Winsock.shutdown returns errorCode:" + errorCode);
// Skip good cases: success, socket already closed.
if (errorCode != SocketError.Success && errorCode != SocketError.NotSocket)
{
// Update the internal state of this socket according to the error before throwing.
SocketException socketException = new SocketException((int)errorCode);
UpdateStatusAfterSocketError(socketException);
if (s_loggingEnabled)
{
Logging.Exception(Logging.Sockets, this, "Shutdown", socketException);
}
throw socketException;
}
SetToDisconnected();
InternalSetBlocking(_willBlockInternal);
if (s_loggingEnabled)
{
Logging.Exit(Logging.Sockets, this, "Shutdown", "");
}
}
示例8: Shutdown
public void Shutdown (SocketShutdown how)
{
if (disposed && closed)
throw new ObjectDisposedException (GetType ().ToString ());
if (!connected)
throw new SocketException (10057); // Not connected
int error;
Shutdown_internal (socket, how, out error);
if (error != 0)
throw new SocketException (error);
}
示例9: SafeSetSocketTimeout
private void SafeSetSocketTimeout(SocketShutdown mode) {
if(Eof){
return;
}
int timeout;
if (mode == SocketShutdown.Receive) {
timeout = ReadTimeout;
} else /*if (mode == SocketShutdown.Send)*/ {
timeout = WriteTimeout;
}
Connection connection = m_Connection;
if (connection!=null) {
NetworkStream networkStream = connection.NetworkStream;
if (networkStream!=null) {
networkStream.SetSocketTimeoutOption(mode, timeout, false);
}
}
}
示例10: SetSocketTimeoutOption
internal void SetSocketTimeoutOption(SocketShutdown mode, int timeout, bool silent) {
GlobalLog.Print("NetworkStream#" + ValidationHelper.HashString(this) + "::SetSocketTimeoutOption() mode:" + mode + " silent:" + silent + " timeout:" + timeout + " m_CurrentReadTimeout:" + m_CurrentReadTimeout + " m_CurrentWriteTimeout:" + m_CurrentWriteTimeout);
GlobalLog.ThreadContract(ThreadKinds.Unknown, "NetworkStream#" + ValidationHelper.HashString(this) + "::SetSocketTimeoutOption");
if (timeout < 0) {
timeout = 0; // -1 becomes 0 for the winsock stack
}
Socket chkStreamSocket = m_StreamSocket;
if (chkStreamSocket==null) {
return;
}
if (mode==SocketShutdown.Send || mode==SocketShutdown.Both) {
if (timeout!=m_CurrentWriteTimeout) {
chkStreamSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, timeout, silent);
m_CurrentWriteTimeout = timeout;
}
}
if (mode==SocketShutdown.Receive || mode==SocketShutdown.Both) {
if (timeout!=m_CurrentReadTimeout) {
chkStreamSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout, silent);
m_CurrentReadTimeout = timeout;
}
}
}
示例11: Shutdown
public void Shutdown(SocketShutdown type)
{
Connection.Shutdown(type);
}
示例12: SafeClose
public static void SafeClose(this Socket socket, SocketShutdown down)
{
try
{
if (socket != null && socket.Connected)
{
socket.Shutdown(down);
socket.Close();
}
}
catch { }
}
示例13: ShutdownSocket
/// <summary>
/// Shuts down the socket.
/// </summary>
/// <param name="how">One of the <see cref="SocketShutdown"/> values that specifies the operation that will no longer be allowed.</param>
private void ShutdownSocket(SocketShutdown how)
{
#if DEBUG_GERT
Console.WriteLine("ID: " + Thread.CurrentThread.ManagedThreadId + " | ChannelForwardedTcpip.ShutdownSocket");
#endif // DEBUG_GERT
if (_socket == null || !_socket.Connected)
return;
lock (_socketShutdownAndCloseLock)
{
var socket = _socket;
if (socket == null || !socket.Connected)
return;
socket.Shutdown(how);
}
}
示例14: Shutdown
public void Shutdown(SocketShutdown how)
{
_remote.Shutdown(how);
}
示例15: Shutdown
public static SocketError Shutdown(SafeCloseSocket handle, bool isConnected, bool isDisconnected, SocketShutdown how)
{
SocketError err = Interop.Winsock.shutdown(handle, (int)how);
if (err != SocketError.SocketError)
{
return SocketError.Success;
}
err = GetLastSocketError();
Debug.Assert(err != SocketError.NotConnected || (!isConnected && !isDisconnected));
return err;
}