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

Netduino Plus 2 - Socket seems to depend on debug

Netduino plus 2 socket static ip error

  • Please log in to reply
3 replies to this topic

#1 MarSko

MarSko

    New Member

  • Members
  • Pip
  • 2 posts

Posted 04 October 2013 - 05:54 AM

Hi there,

 

I'm using the Netduino Plus 2 to intercept some tcp messages on port 9100, and it seems to work, at least most of the times when connected with the debugger.

 

A simple test can be done by using a browser with the following url: http://ip_address:9100

 

I'm using a blocking tcp socket, and the socket.accept() hangs until a request is sent - which should be fine.

This mostly works when connected with the debugger, but some times nothing is being accepted. When trying without the debugger connected, it never works.

 

A static ip is being used, and dhcp is turned of.

 

Anyone with any ideas?

Martin



#2 Jason.Net

Jason.Net

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts

Posted 05 October 2013 - 11:44 AM

Hi Martin

 

It would only be a guess but if it is working in the debugger and is not working without it then I would look at timing. The debugger introduces delays as it inspects the state of the device, handles Debug.Print (even in release mode), checks break points etc.

 

Without seeing your code I would guess that you are jumping straight from accept to reading how many bytes you have available. Without the debugger this could return zero or if you don't wait for the whole header to be received you won't get the full request. There are plenty of example web servers to look at if you Google Netduino Webserver but the 'standard' way is something like

 

Cheers

using (Socket client = clientSocket.Accept()){    Thread.Sleep(10);    int availableBytes = 0;    do    {        int bytes = client.Available - availableBytes;        if (bytes == 0)            break;        availableBytes += bytes;        Thread.Sleep(5);    } while (true);    if (availableBytes > 0)    {....    }


#3 MarSko

MarSko

    New Member

  • Members
  • Pip
  • 2 posts

Posted 07 October 2013 - 11:43 AM

Hi,

 

i really stripped down my project - to pretty much a copy of the suggest code, but stil a lot of problems.

 

Know even then ping of the dut will fail in debug mode - I have tried a complete erase of the netduino and a new flash of the firmware, but stil the problem exists.

 

I did fill in the correct mac address and ip address after the complete erase.

 

Any ideas?

 

Martin



#4 NoxiaZ

NoxiaZ

    Member

  • Members
  • PipPip
  • 12 posts

Posted 07 October 2013 - 09:47 PM

Hi,

 

i really stripped down my project - to pretty much a copy of the suggest code, but stil a lot of problems.

 

Know even then ping of the dut will fail in debug mode - I have tried a complete erase of the netduino and a new flash of the firmware, but stil the problem exists.

 

I did fill in the correct mac address and ip address after the complete erase.

 

Any ideas?

 

Martin

 

Paste your code, its nearly impossible to help you without seeing you code :)







Also tagged with one or more of these keywords: Netduino plus 2, socket, static ip, error

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.