2 arduino mega connect with ethernet

Hello i want to connect two arduino mega with ethernet.example first arduino ip adress 192.168.5.1 and second is 192.168.5.2.first send to second arduino one integer or word or any variable.after second send acknowledge message..after i want to make little arduino network with more arduino.how can do this pls help me

When you get two PCs talking to each other, over ethernet, adapting the code to the Arduino will be trivial.

i know but i dont know how can do this in arduino.someone tell me how can i do that.chatserver or udp which one .pls i want simple code example for learning