C#远程抛出错误 [英] C# Remoting Throwing an error

查看:96
本文介绍了C#远程抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


一段时间我正在使用远程访问其他程序中的功能点网抛出erorr(非阻塞套接字操作无法立即完成)
我该如何解决这个问题,请帮忙. .

服务器端代码


I am using remoting to access function in another program some time Dot net throwing an erorr (A non-blocking socket operation could not be completed immediately)
how can i solve this problem pls help. .

server side code

public string IsServerActive()
     {
         return "SUCCESS";
     }



客户端代码



client side code

private bool IsServerExists(string ServerIP, string ServerPort)
    {
        try
        {
            bool connectionStatus = false;
            ChannelServices.RegisterChannel(new TcpClientChannel(),false);
            Type requiredType = typeof(IServerInterface);
           IServerInterface gblRemoteObject  = (IServerInterface)Activator.GetObject(requiredType, "tcp://" + ServerIP + ":" + ServerPort + "/ServerRequest");
            if (gblRemoteObject.IsServerActive().Trim() == "SUCCESS")
                connectionStatus = true;
            return connectionStatus;
        }
        catch
        {
            return false;
        }
 
    }

推荐答案

您在此处未显示任何代码,因此我将不得不猜测您所拥有的,但是我怀疑问题出在非阻塞套接字上的Connect同步调用中.我倾向于宁愿使用BeginConnect/EndConnect而不是同步使用它.
You haven''t shown any code here so I''m going to have to guess what you''ve got, but I suspect the issue is in a synchronous call to Connect on a non blocking socket. Rather than using it synchronously, I tend to prefer to use BeginConnect/EndConnect instead.


这篇关于C#远程抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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