Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

problems in Netduino,as server (comunication ethernet)


  • Please log in to reply
2 replies to this topic

#1 davasquez

davasquez

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 November 2012 - 12:20 AM

Hi, for the second time i posted this situation. I want to send a message from PC to Netduino plus via Ethernet,and this see in the debugger. I configurated the Ip Netduino`s in the MF deploy. Your Ip is 192.168.10.11,and the Pc is 192.168.10.10 but this is not visible in the debugger. Where is my error in the code? (Do not want to leave the ND+ i would like to move forward, help me please)

code PC:
                sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("192.168.10.11"), 44818);
                try
                {
                    sck.Connect(localEndPoint);
                }
                catch
                {
                    Console.Write("Unable to connec to remote end point \r\n");
                    Main(args);
                }
     
                string text = "hola desde PC";
                    byte[] data = Encoding.UTF8.GetBytes(text);
                while (true)
                {
                    sck.Send(data);
                System.Threading.Thread.Sleep(1000);
                }

Code Netduino Plus:

 OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 44818);
            sck.Bind(localEndPoint);
            sck.Listen(10);
            Socket clientSocket;
            while (true)
            {
                clientSocket = sck.Accept();

                while (clientSocket != null)
                {
                    try
                    {
                        Byte[] buffer = new Byte[1024];

                        clientSocket.Receive(buffer);
                        clientSocket.Send(buffer); // send back the data
                        string request = new string(Encoding.UTF8.GetChars(buffer));
                        Debug.Print(request);
                    }
                    catch
                    {
                        clientSocket = null;
                    }
                }

Edited by Chris Walker, 30 November 2012 - 09:19 AM.
added [code][/code] tags


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 November 2012 - 09:19 AM

Moderator question: To avoid duplicate replies...could you please send me the link to your original post so we can remove one or the other? And then if you haven't gotten any guidance yet--make sure you do? Thank you, Chris

#3 davasquez

davasquez

    Member

  • Members
  • PipPip
  • 16 posts

Posted 02 December 2012 - 04:24 PM

Thanks Walker, I had already solve the problem, I used DHCP (Lan of my University, in my house did not work).




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.