System.Net.Sockets.SocketException [英] System.Net.Sockets.SocketException

查看:74
本文介绍了System.Net.Sockets.SocketException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

这是我的问题。我知道它有一个注释问题,但我认为这里的内容有所不同。

Here's my problem. I know its a commented problem but I think its something different in here.

System.Net.Sockets.SocketException:"现有连接被远程主机强行关闭"

System.Net.Sockets.SocketException: "An existing connection was forcibly closed by the remote host"

我有远程服务器和客户端。

I have remoting server and client.


  • 当我连接&断开客户端如果我想再次与客户端连接,我必须重新启动服务器,否则:

服务器堆栈跟踪:

  在System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)

  在System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential,String targetName,ProtectionLevel requiredProtectionLevel,TokenImpersonationLevel allowedImpersonationLevel)

   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream,String machinePortAndSid)

  在System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateSocketHandler(套接字套接字,SocketCache socketCache,String machinePortAndSid)

  在System.Runtime.Remoting.Channels.SocketCache.CreateSocketHandler(套接字套接字,String machineAndPort)

  在System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint)

  在System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()

  在System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid,Boolean openNew)

   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg,ITransportHeaders requestHeaders,Stream requestStream)

  在System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg,ITransportHeaders requestHeaders,Stream requestStream,ITransportHeaders& responseHeaders,Stream& responseStream)

   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)



异常重新收到[0]:

   ;在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)

  在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)

  在RemotingLibrary.Library.getConfiguration()

   at C:\ Client \DevicesList.cs中的Client.DevicesList.logoffToolStripMenuItem_Click(Object sender,EventArgs e):第102行。
  在System.Windows.Forms.ToolStripItem.RaiseEvent(Object key,EventArgs e)

  在System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)

  在System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

  在System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

  在System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,ToolStripItemEventType符合)

  在System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,ToolStripItemEventType符合)

  在System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

  在System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)

  在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击)

  在System.Windows.Forms.Control.WndProc(消息& m)

  在System.Windows.Forms.ScrollableControl.WndProc(消息& m)

  在System.Windows.Forms.ToolStrip.WndProc(消息& m)

  在System.Windows.Forms.ToolStripDropDown.WndProc(消息& m)

  在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m)

  在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m)

  在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

  在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

  在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID,Int32 reason,Int32 pvLoopData)

  在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,ApplicationContext context)

  在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,ApplicationContext context)

  在System.Windows.Forms.Application.Run(Form mainForm)

  在Client.Program.Main()中的C:\ Client \Program.cs:第24行

  在System.AppDomain._nExecuteAssembly(Assembly assembly,String [] args)

  在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)

  在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

  在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)

  在System.Threading.ThreadHelper.ThreadStart()

Server stack trace:
   at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream, String machinePortAndSid)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateSocketHandler(Socket socket, SocketCache socketCache, String machinePortAndSid)
   at System.Runtime.Remoting.Channels.SocketCache.CreateSocketHandler(Socket socket, String machineAndPort)
   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint)
   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
   at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at RemotingLibrary.Library.getConfiguration()
   at Client.DevicesList.logoffToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Client\DevicesList.cs:line 102
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at Client.Program.Main() in C:\Client\Program.cs:line 24
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

 

 


  • 当客户端连接时没有其他客户端可以连接,但如果我尝试与另一个客户端同时连接,则会出现:

我是C#& .NET Remoting。在这种情况下我应该尝试什么。

I'm new to C# & .NET Remoting. What should I try in this case.

如果您有在线资料和任何其他推荐人的链接,欢迎他们! :)

If you have links to online materials and any other referrers they are welcome! :)

推荐答案

您好

您我们无法真正帮助您完成上述信息。很难从代码中分辨出来。你确定你没有进行任何跨线程的电话。

You we can not really help you with that info above. hard to tell from that code. are you sure you are not making any cross thread calls.

在codeproject.com上有一些很好的客户端服务器应用程序

There are some good exmaple of client server apps on codeproject.com

  ;

干杯

 


这篇关于System.Net.Sockets.SocketException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆