mhowlett / NNanomsg

.NET binding for nanomsg
MIT License
179 stars 52 forks source link

PAIR example not receiving data. #28

Closed katsuragi545 closed 7 years ago

katsuragi545 commented 7 years ago

I'm currently trying to learn nanomsg. I've downloaded the project and I am trying to get the Pair example to work. The SendReceive() function in Pair.cs has this code:

        static void SendReceive(PairSocket s)
        {
            NanomsgSocketOptions.SetTimespan(s.SocketID, SocketOptionLevel.Default, SocketOption.RCVTIMEO, TimeSpan.FromMilliseconds(100));
            while (true)
            {
                var data = s.Receive();
                if (data != null)
                {
                    Console.WriteLine("RECEIVED: '" + Encoding.UTF8.GetString(data) + "'");
                }
                Thread.Sleep(TimeSpan.FromSeconds(1));
                s.Send(Encoding.UTF8.GetBytes("the message is " + DateTime.Now.ToLongTimeString()));
            }
        }

When I run the program, I expect to eventually see the RECEIVED WriteLine message in the console, but I have yet to see it. Since I am new to this, I'm guessing that I may be doing something wrong.

Here are the steps I use to run the program.

1) Rebuild the solution in Visual Studio 2) Open two command prompts in the Debug folder that contains Example.exe. 3) Run the command Example.exe Pair node0 inproc://proc_test in command prompt 1 4) Run the command Example.exe Pair node1 inproc://proc_test in command prompt 2

Those run fine without error, but nothing shows up as being received. What am I doing wrong?

katsuragi545 commented 7 years ago

Figured it out. The address parameter I was using apparently isn't valid (though it works with Test_Pair()?). I changed the address in both commands to tcp://127.0.0.1:1234 and it worked.