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

Right code for DHCP?

ethernet dhcp lan network webserver web server

  • Please log in to reply
1 reply to this topic

#1 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 28 March 2013 - 08:08 AM

Hey guys,

I'm currently looking over my webserver code and have the following question:

I never used DHCP, always fixed IP.

What would be the right code to receive a IP via DHCP from my router. Is the following code correct (DhcpEnable ist just a bool I set)

if ( DhcpEnable )		    {			    //Dynamic IP			    interf.EnableDhcp( );			    interf.RenewDhcpLease( );		    }		    else		    {			    //Static IP			    interf.EnableStaticIP(ipAddress, subnetMask, gatewayAddress);		    } 

Greets, Markus


NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 March 2013 - 05:23 PM

Hi Markus,<br /><br />That looks right. You may not need to do the .RenewDhcpLease() after .EnableDhcp.<br /><br />Also--this will update your network configuration which may fill up the config sector. I would recommend that you only change the IP settings when you need to change them. Otherwise--you can just leave them as-is.<br /><br />Chris





Also tagged with one or more of these keywords: ethernet, dhcp, lan, network, webserver, web, server

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.