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

Socket programming unreliable


  • Please log in to reply
9 replies to this topic

#1 Nicolas Dorier

Nicolas Dorier

    Member

  • Members
  • PipPip
  • 24 posts

Posted 26 February 2011 - 10:54 PM

I have tried to program sockets with the netduino in v4.1.0 (update 5) and v4.1.1 ALPHA 7.
From what I have seen, I had some problems.
Sometimes, call to bind like this
server.Bind(new IPEndPoint(IPAddress.Parse("192.168.5.100"), 5656));
completely blocks the netduino (even MFDeploy can't ping it after that)

Sometimes it does not block but throw an exception which means that no interface have this IP
And sometimes, after several reboot, without doing anything, it works.

Most of the time, when I use sockets, I can't deploy without replugging the USB cable.
And MFDeploy can't ping when the server is on.

Am I doing something wrong ?

Here two project, "Portal.Debug.Client" is a WPF test client which connect and "ping" the netduino.
"Portal.Debug" just listen for a client, and send back the data it recieves.

Sometimes it does not work, sometimes it work, it's very unreliable.

Attached Files



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 February 2011 - 01:15 AM

Hi Nicolas, That's very odd. What happens if you pass in an IP address parameter of IPAddress.Any? Also, what are your IP settings? MAC address? [Also, if you upgraded your firmware...did you reset your MAC address back to the one on the sticker attached to your Netduino Plus?] For firmware, I'd recommend using 4.1.0.6 RC2 or 4.1.1 a7. We've been fixing quite a few bugs in the lwIP networking implementation over the last few months (which are incorporated in the newest releases). Let's see what we can do to create a reasonably consistent repro case...and then we can dig into it and trace through things here. Chris

#3 Nicolas Dorier

Nicolas Dorier

    Member

  • Members
  • PipPip
  • 24 posts

Posted 27 February 2011 - 08:30 AM

I had not reset the MAC address, I just did but same problem here how I do :

-Run in debug the two projects
-Click on "Ping" from the WPF application
(Here I test several pings and it works fine...)
-Click "Renew"...
(Here the "socket.Connect of the wpf application works, whereas the netduino is not blocked on socket.Accept)
-Click" Ping"
(Does not work)
-Stop debug,
-Unplug the netduino
-Replug
-Run in debug the two projects
-Now the netduino is blocked on server.Bind

Every time I unplug/replug the netduino it blocks on server.Bind... and by chance it works again once

I use 4.1.1 a7, thanks for your help !! :)

Update

Same problem when I use UDP.
sometimes it blocks on server.Bind, sometimes it blocks when I create the socket
Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);


#4 Nicolas Dorier

Nicolas Dorier

    Member

  • Members
  • PipPip
  • 24 posts

Posted 28 February 2011 - 04:56 PM

When I instanciate the Socket object, the netduino crashs (Even tinybooter does not respond) I have found a workaround : I need to put a breakpoint between the new Socket, and the Bind and plug the ethernet cable at this time. :(

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 02 March 2011 - 12:55 AM

Hi Nicolas, Hmm, that shouldn't be happening. We will pull your code up on a development machine within the next few days and will see if we can reproduce the issue. Chris

#6 Nicolas Dorier

Nicolas Dorier

    Member

  • Members
  • PipPip
  • 24 posts

Posted 02 March 2011 - 12:28 PM

The workaround was to use the NetworkChange.NetworkAvailabilityChanged event. I unplug the ethernet cable when the netduino start, when it's started, I plug the ethernet cable and then I start a new thread in the event handler and opens the socket.

#7 gaibwm

gaibwm

    New Member

  • Members
  • Pip
  • 4 posts

Posted 07 March 2011 - 07:23 PM

I have tried to program sockets with the netduino in v4.1.0 (update 5) and v4.1.1 ALPHA 7.
From what I have seen, I had some problems.
Sometimes, call to bind like this

server.Bind(new IPEndPoint(IPAddress.Parse("192.168.5.100"), 5656));
completely blocks the netduino (even MFDeploy can't ping it after that)

Sometimes it does not block but throw an exception which means that no interface have this IP
And sometimes, after several reboot, without doing anything, it works.

Most of the time, when I use sockets, I can't deploy without replugging the USB cable.
And MFDeploy can't ping when the server is on.

Am I doing something wrong ?

Here two project, "Portal.Debug.Client" is a WPF test client which connect and "ping" the netduino.
"Portal.Debug" just listen for a client, and send back the data it recieves.

Sometimes it does not work, sometimes it work, it's very unreliable.



I run it a few weeks ago and it is still running. I will post my codes, if issue is not solved.

#8 Nicolas Dorier

Nicolas Dorier

    Member

  • Members
  • PipPip
  • 24 posts

Posted 07 March 2011 - 08:57 PM

The issue is not solved, can you send me your code please ? I think I did it right... maybe my netduino is buggy

#9 Stephen_P

Stephen_P

    New Member

  • Members
  • Pip
  • 7 posts

Posted 08 March 2011 - 09:25 AM

I'm not sure if this is going to be useful but I had very similar problems with my netduino plus but they all went away after I bypassed my 10BASE-T hub. The hub which appears to have been causing the problem is not in my office here so I haven't been able to re-connect it to verify that it was definitely the problem but I would suggest if you are having issues try avoid the hub. Hope that helps a bit. Cheers Stephen

#10 gaibwm

gaibwm

    New Member

  • Members
  • Pip
  • 4 posts

Posted 15 March 2011 - 06:53 PM

Instanciated, "call" function will create a thread to connect and receive in "Receive" function until connection is terminated

Attached Files






0 user(s) are reading this topic

0 members, 0 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.