Can I establish a communication between two arduinos only by using the ethernet?

I want to send some words between arduinos only by using the ethernet shields and the ethernet cable. Can I do this? How? What code can I use? I have already tried to establish aSerial communication using the Rx and Tx and it worked but the problem is the distance between the arduinos, so I decided to try by using ethernet cable.

See this thread: It could work.

You can probably do this with ethernet, but RS422/RS485 sounds like a better fit given your problem description. If you set it up in an RS422 configuration (one way communication on a twisted wire pair, 2x twisted wire pairs for bi-directional communication) this allow you to use the software from your serial approach directly. The difference is that your serial signal will be converted to a differential signal at the Tx end and converted back at the Rx end of the cable. The standard is specified to work over hundreds of meters.