I understand the basics of how ARP works, one host sends out a MAC Broadcast with "Who has this IP?" and some host in the network answers with "I have that IP".
But what happens if a Router is connected to the same LAN, the routers function would be to connect the LAN to the WAN (hope I got that right). Does the host asking for the adress then automatically switch and send a message to the connected router with his data or what happens?
What happens is, that your IP stack first determines to where it needs to send the packet to. If it goes to an IP address that is in a directly connected network, it will send the packet directly, otherwise, it will send the packet to the gateway.
This may sound abstract to you. For a simple case, suppose you have the following network:
host_a host_b
+----------+ +----------+
|10.1.1.101| |10.1.1.102|
+-----+----+ +-----+----+
| | +--------+ <--------->
-----+--------------+-----------+10.1.1.1|--------< INTERNET >
+--------+ <--------->
Router
On your host_a, you will have
On your host_b, you will have
Suppose host_a wants to send a packet to 10.1.1.102. If you use the IP address and netmask, you see that it is in the same subnet. So, host_a will send an ARP-request onto the network asking "Hey, who has 10.1.1.102?" Host_b will respond with its MAC-ID.
Now suppose host_a wants to send to 8.8.8.8. That is not on the local network. So, host_a will now send it to its default gateway, 10.1.1.1. Host_a will send an ARP-request "Hey, who has 10.1.1.1?" and the router will respond with its MAC-ID.
The procedure above is a great simplification of what actually happens, but it may help you a step further in how your network works.
(the question may be more appropriate for another SE site, but then someone will probably migrate it)