Code to Start the Ethernet connection?

Example sketch (Ethernet PrintDHCP IP address):

why is this piece of code necessary? w/out it, my IP doesn't print. and when it does print (when code is included), there is no "Failed to configure bla bla" msg on Serial.

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }

does this code initiate the connection somehow or does it just have something to do with printing?

That begin() requires a dhcp server on the localnet to issue an IP address. Most routers have a dhcp server on the local interface by default. That code does initiate a packet exchange with the router to obtain the network settings from the router.

That code does initiate a packet exchange with the router to obtain the network settings from the router.

but how though? regardless of the boolean, the loop body has only a message, and a for(;;);

the message is just, well.. a message, but the second one idk what it does, maybe this is what initiates it somehow? idk, what exactly does the empty for loop do?

If Ethernet.begin(mac) returns 0, that means the dhcp request failed. There is no IP or network settings to display, so it stops the program forever in that for loop.

If Ethernet.begin(mac) returns 0, that means the dhcp request failed. There is no IP or network settings to display, so it stops the program forever in that for loop.

that's exactly where i'm confused; this code only provides an alternative route to take if everything DOESN'T go as it's supposed to; except, everything does indeed work as it's supposed to.

when i include this piece of code it never seems to get executed. yet when i remove it, the program stops.

Have you tried assigning a static IP to the ethernet shield?

Do you have a SD card in the shield's slot?

why is this piece of code necessary?

It can give you a hint as to why your code might not be working as desired. If you are having troubles, make your w5100 shield pins are in the correct holes and your ethernet cable is not bad.