user72224: So I have several specific question connected to this topic and I'm aware of the conceptual answers and I'm only interested in the technical details (with programming terms and concepts as I'm a developer). 
My questions are:

If I'm sending a transaction from my wallet application (e.g. electrum), what does it do under the hood? Does it use the HTTP protocol or something else? Or not even use TCP but UDP instead?
How does the miners "listen" to transactions? Do they listening on some port? Is there any generic protocols for "listening" like this?
When a miner mines a block how does he/she broadcast it to the network? Is it the same as sending a transaction from my electrum wallet?


user62184: I don't know the answers to all questions but let me try to help (most of the above is not verified).

https://bitcoin.org/en/full-node#port-forwarding
Bitcoin nodes use ports 8333 to listen to new transactions and blocks.
Unfortunately in the picture both TCP and UDP port forwarding is selected so I cannot reason which one is used. I assume it is not HTTP as port 8333 is used. EDIT: As per Pieter's comment TCP is used.
(If you have full node with wallet you do the above. If you have lightweight wallet you send your transaction to some full node that does the above process.)
EDIT per Pieter's comment. The miners (full nodes) listen on port 8333 for inbound connections. Other nodes can establish connection with that node on that port. Also the node itself can establish outbound connections to other nodes that listen for inbound connections on port 8333. It is not necessary to allow for inbound conections. When connection (oubound or inbound) is established between two nodes they exchange transactions and blocks when they a) make transaction, b) mine a block, or c) receive transaction or block from some other node.  Each full node holds several connections. What is the specific protocol, and if some common exist I don't know.
These websites are running servers that have full bitcoin node (more likely more they have more than one node). This node contains all information about the blockchain and pool of pending transactions (as every full node does). The servers crawl this information and store the data and statistics in their databases. The website is just the frontend that shows this information from these databases.
EDIT per Pieter's comment. The node (miner) broadcasts the new block to all nodes it has connection with. More commonly the miner mines in pools so it sends the new block to the pool server, which acts as a node and does the above.


user208: The Bitcoin P2P network
The Bitcoin P2P network is a randomly-wired gossip network. This means that all nodes make arbitrary connections to other peers (using various ways to discover new addresses) using a custom TCP protocol, usually using port 8333. Typical nodes create 8 outgoing connections, and if publicly reachable, accept up to a few 100 incoming connections.
It being a gossip network means that nodes send messages to each other of the form "do you have block with hash X" or "do you have transaction with hash X", after which the peer can respond by asking for the full transaction or block. Simplified, this means that eventually every node learns about every block. The protocol is bidirectional - it doesn't matter who connected to whom; both peers will announce if they have something they don't know the other side already has as well.
Not all network nodes are reachable. Some only make outgoing connections. Sometimes setups are used where someone runs a publicly reachable node, and then runs a second private node that only connects out to their own public node, thereby giving some extra privacy and reduced attack surface.
Not all network nodes validate the blocks and transactions they see and pass on. Nodes that do are called full nodes.
Miners (or at least mining pools) run nodes like this, picking up transactions their nodes learn about, assembling them into candidate blocks, hashing to find a nonce, and if they succeed, broadcast the resulting block out to their peers using the same P2P network. Miners in this way are not special - people don't directly submit things to miners.
Since recently, an extension to the protocol is used to relay blocks much more efficiently, called Compact Blocks. It makes use of the fact that most nodes will already have most of the transactions that are added to a new block.
Specialized relay networks
Additional networks exist of groups of nodes that use specialized protocols to very quickly interconnect nodes. One such protocol is FIBRE, which is in fact UDP based and makes heavy use of error correcting codes to avoid roundtrips.
Electrum
Ironically, Electrum in your question is a bad example. Electrum is not a P2P client (not even a light one). Instead, it uses a client-server architecture, and connects to specialized servers (which are themselves Bitcoin P2P nodes however).

72224: <p>So I have several specific question connected to this topic and I'm aware of the conceptual answers and I'm only interested in the technical details (with programming terms and concepts as I'm a developer). </p>

<p><strong>My questions are:</strong></p>

<ol>
<li><p>If I'm sending a transaction from my wallet application (e.g. electrum), what does it do under the hood? Does it use the HTTP protocol or something else? Or not even use TCP but UDP instead?</p></li>
<li><p>How does the miners "listen" to transactions? Do they listening on some port? Is there any generic protocols for "listening" like this?</p></li>
<li><p>When a miner mines a block how does he/she broadcast it to the network? Is it the same as sending a transaction from my electrum wallet?</p></li>
</ol>
 62184: <p>I don't know the answers to all questions but let me try to help (most of the above is not verified).</p>

<ol>
<li><p><a href="https://bitcoin.org/en/full-node#port-forwarding" rel="nofollow noreferrer">https://bitcoin.org/en/full-node#port-forwarding</a>
Bitcoin nodes use ports 8333 to listen to new transactions and blocks.
Unfortunately in the picture both TCP and UDP port forwarding is selected so I cannot reason which one is used. I assume it is not HTTP as port 8333 is used. EDIT: As per Pieter's comment TCP is used.
(If you have full node with wallet you do the above. If you have lightweight wallet you send your transaction to some full node that does the above process.)</p></li>
<li><p>EDIT per Pieter's comment. The miners (full nodes) listen on port 8333 for inbound connections. Other nodes can establish connection with that node on that port. Also the node itself can establish outbound connections to other nodes that listen for inbound connections on port 8333. It is not necessary to allow for inbound conections. When connection (oubound or inbound) is established between two nodes they exchange transactions and blocks when they a) make transaction, b) mine a block, or c) receive transaction or block from some other node.  Each full node holds several connections. What is the specific protocol, and if some common exist I don't know.</p></li>
<li><p>These websites are running servers that have full bitcoin node (more likely more they have more than one node). This node contains all information about the blockchain and pool of pending transactions (as every full node does). The servers crawl this information and store the data and statistics in their databases. The website is just the frontend that shows this information from these databases.</p></li>
<li><p>EDIT per Pieter's comment. The node (miner) broadcasts the new block to all nodes it has connection with. More commonly the miner mines in pools so it sends the new block to the pool server, which acts as a node and does the above.</p></li>
</ol>
 208: <p><strong>The Bitcoin P2P network</strong></p>

<p>The <a href="https://bitcoin.org/en/developer-reference#p2p-network" rel="nofollow noreferrer">Bitcoin P2P network</a> is a randomly-wired gossip network. This means that all nodes make arbitrary connections to other peers (using various ways to discover new addresses) using a custom TCP protocol, usually using port 8333. Typical nodes create 8 outgoing connections, and if publicly reachable, accept up to a few 100 incoming connections.</p>

<p>It being a gossip network means that nodes send <a href="https://bitcoin.org/en/developer-reference#inv" rel="nofollow noreferrer">messages</a> to each other of the form "do you have block with hash X" or "do you have transaction with hash X", after which the peer can respond by asking for the full transaction or block. Simplified, this means that eventually every node learns about every block. The protocol is bidirectional - it doesn't matter who connected to whom; both peers will announce if they have something they don't know the other side already has as well.</p>

<p>Not all network nodes are reachable. Some only make outgoing connections. Sometimes setups are used where someone runs a publicly reachable node, and then runs a second private node that only connects out to their own public node, thereby giving some extra privacy and reduced attack surface.</p>

<p>Not all network nodes validate the blocks and transactions they see and pass on. Nodes that do are called full nodes.</p>

<p>Miners (or at least mining pools) run nodes like this, picking up transactions their nodes learn about, <a href="https://bitcoin.org/en/developer-reference#getblocktemplate" rel="nofollow noreferrer">assembling them into candidate blocks</a>, hashing to find a nonce, and if they succeed, broadcast the resulting block out to their peers using the same P2P network. Miners in this way are not special - people don't directly submit things to miners.</p>

<p>Since recently, an extension to the protocol is used to relay blocks much more efficiently, called <a href="https://bitcoincore.org/en/2016/06/07/compact-blocks-faq/" rel="nofollow noreferrer">Compact Blocks</a>. It makes use of the fact that most nodes will already have most of the transactions that are added to a new block.</p>

<p><strong>Specialized relay networks</strong></p>

<p>Additional networks exist of groups of nodes that use specialized protocols to very quickly interconnect nodes. One such protocol is <a href="http://bitcoinfibre.org/" rel="nofollow noreferrer">FIBRE</a>, which is in fact UDP based and makes heavy use of error correcting codes to avoid roundtrips.</p>

<p><strong>Electrum</strong></p>

<p>Ironically, Electrum in your question is a bad example. Electrum is not a P2P client (not even a light one). Instead, it uses a client-server architecture, and connects to specialized servers (which are themselves Bitcoin P2P nodes however).</p>
