Shop OBEX P1 Docs P2 Docs Learn Events
How do I change listening port after DHCP? — Parallax Forums

How do I change listening port after DHCP?

Skywise711Skywise711 Posts: 37
edited 2015-03-19 23:41 in Accessories
I'm using the Wiznet 5200 quickstart to learn ethernet comms.

My goal is UDP communications with PC software I'm writing in C/C++. I have successfully done so, but I've been using hard coded static IP's on the hardware end. I would now like to use DHCP. I've successfully implemented that from the sample code. I want to use DHCP because this project is being done with the goal of developing a commercial product for sale, and I want to avoid encumbering the user with having to play with setting IP addresses on the hardware. Discovery and handshaking with the hardware will be handled from the PC software for a near "plug and play" experience (also successfully done using static IP's and broadcast UDP packets).

But now, I want to change the port number I'm listening to. After the DHCP process it appears I'm still listening on port 68. I don't see any obvious way to change this. The "Socket" code has commands for setting the remote IP and port, that is, where I'm sending packets to. I did see a PRI SetSocketPort() in the W5200 code, and I tried making it public and using it, but no joy. Probably not the right way to do things.

In fact, after the DHCP code, I can't seem to do anything else, send or receive packets. I'm monitoring things with Wireshark. I've tried all sorts of ideas, just shooting in the dark but I don't seem to be hitting anything.

I really wish there was a "from the ground up" tutorial. I've never done ethernet programming before so I'm learning this from scratch. Trial and error has it's limitations.

Brian

PS Thank you Mike G for your code on google. I had problems with the code on the W5200 product page not working, but your updates did work.

Comments

  • Skywise711Skywise711 Posts: 37
    edited 2015-03-19 23:41
    OK. Figured it out myself after more pondering, more trial and error, and more attempts at analyzing the sample code. To some this may sound like a "well, duh!!!" moment, but all I did was open a new socket with the parameters I need.

    <gripe>
    It would be really nice if there was a "from the ground up" tutorial.

    Regardless, sample code released with a product should always be fully documented and commented.

    Just because one can read the code doesn't mean one will understand it. Sure, you can see 'what' to do, but understanding comes from knowing 'how' it works and 'why' you have to take those steps.
    </gripe>

    Brian
Sign In or Register to comment.