Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
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. .

code
server side code
C#
public string IsServerActive()
     {
         return "SUCCESS";
     }


client side code
C#
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;
        }

    }
Posted
Updated 4-Jul-11 22:30pm
v2

I found an answer by googling the error message.

http://www.lesnikowski.com/blog/index.php/a-non-blocking-socket-operation/[^]

John T. Angle Says:
June 11th, 2010 at 14:20

Try resetting Blocking property before each of your reader.ReadLine() statements. In C# that is “client.Blocking = true;”, I’m not sure what it is in VB.

We had same problem in .NET3.5 which *seems* to have been resolved with this approach.
 
Share this answer
 
I have done some thing similar,in making DB configuration of an application and its working fine,hope it'll help you

private bool Test()
        {
            bool rvalue = false;
            //Connection String for Windows Authentication
            string cnstr = @"Data Source=" + dbnametxt.Text + ";Initial Catalog=DBname;Integrated Security=True";
            //Connection String for SQL Server Authentication
            string sqlcnstr = @"Data Source=" + dbnametxt.Text + ";Initial Catalog=DBname;uid=" + uidtxt.Text + ";pwd=" + pwdtxt.Text + ";";
            if (radioButton1.Checked)
            {
		//create new connection conn with cnsts
            }
            else if (radioButton2.Checked)
            {
               //create new connection conn with sqlcnstr,and ask for authentication
            }
            if (conn.OpenCon())//checking if server is valid or not,OpenCon() will return true if connection is opened 
            {
                rvalue = false;
            }
            else
            {
                rvalue = true;
            }
            return rvalue;
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900