How do network nodes "connect" - amateur level I have little background in computing, have been studying bitcoin for intellectual stimulation. I have learned a lot and I understand quite a bit regarding the function of nodes, the validations they perform, and their importance to bitcoin functionality - but I want to understand more about how nodes in the network &quot;connect&quot;. I read this question and it didn't help.
I have no idea what a &quot;network&quot; really is. I googled and read about LAN/WAN. Are these the types of network we're talking about?
For example - if I owned bitcoin before the bitcoin cash fork, it is my understanding that I could choose to send my coin as bitcoin, or send it as bitcoin cash, it just depends which network I send the transaction to (kind of, over simplyfing here). So if I send it from a bitcoin wallet it will get broadcasted to the bitcoin network and stay on the bitcoin blockchain, or if I send it from a bcash wallet it will get formatted however bcash formats tx messages and get broadcast to the bcash network. How do these &quot;networks&quot; work, how are they distinct? Where could I look to read more about this.
Certainly if I download bitcoin core and start running a full node it will start connecting me to other nodes in the bitcoin network. How does that process actually go down? How do distinct networks stay separate? I have read about things &quot;dishonest nodes&quot; can do, so without downloading something like bitcoin core (which I assume automatically implements standard protocol for node behavior) how would nodes connect to the network without running bitcoin core?
Hopefully someone can make sense of my question, I understand it may not be very clear but that is because I don't even know enough to form a good question. I don't have any terminology here.
Edit: maybe this will help understand. Supposed I wanted to write some code to develop my own bitcoin client. What was that code look like?
I have no idea what a &quot;network&quot; really is. I googled and read about LAN/WAN. Are these the types of network we're talking about?

No. A network is really just &quot;a group of connected things&quot;. One example is indeed a LAN network through which multiple computers that are physically close to each other (a home, an office, ...) are connected to each other. The Internet is also an example of a network - one built up of smaller and very distinct networks like LANs.
But networks can be many more things than that. The group of people you know and hang out with is considered a network too. An electrical circuit inside a machine is sometimes called a network. I bring up these examples, because the word &quot;network&quot; in a computer setting often evokes the mental image of physical interconnections between computers - and while that is one example, the Bitcoin network is something fundamentally different.
The Bitcoin peer-to-peer network consists of Bitcoin nodes - pieces of software, not hardware. I could be running two nodes on my own computer, and they could be connected to each other - or not; they could also both just be connected to far away nodes elsewhere in the world. In fact, these connections don't even need to be established over the Internet. There have been projects to connect Bitcoin nodes over mesh networks, and you could arguably also consider the Blockstream satellite service to be part of this network.
So bottom line, the Bitcoin network consists of pieces of software talking to each other. How they talk to each other can differ, though most commonly, it is TCP/IP connections over the public Internet or over Tor. These connections are somewhat similar to the connection your browser makes to stackexchange.com to show you this answer, but instead of it just being many clients (browsers) talking to one server (stackexchange), it is all nodes that are equal - they are peers. No servers and clients; there are just nodes, and they each connect to one or multiple other nodes. Certainly some are more powerful or better connected than others, but none have a privileged position w.r.t. other nodes.

How do these &quot;networks&quot; work, how are they distinct?

This is where it gets interesting. Bitcoin, and similar things, follow a trust-minimized design. At least if you run a fully-validating node (like Bitcoin Core), your node will generally not trust anything other nodes tell it. They will exchange blocks, and transactions, and other things, but whatever your node receives it will validate independently to the extent possible. This includes very strict validity rules for blocks. Your node will only accept blocks that follow the exact rules implemented in the software.
The simple answer to your question is that Bitcoin and altcoin nodes have different rules, and simply won't accept each others blocks. If a node were to be only connected to nodes with different rules, it would be isolated, and not be able to learn about new Bitcoin blocks; it needs at least one connection to an honest like-minded node. To make sure that doesn't happen, nodes will detect the situation where their peers give them blocks they consider invalid, and when that happens, more aggressively look for more nodes to connect to, and possibly disconnect existing ones if they really seem to have a different idea. In practice, this quickly teaches nodes on both sides after a fork to shun the other side.

Certainly if I download bitcoin core and start running a full node it will start connecting me to other nodes in the bitcoin network. How does that process actually go down?

Bitcoin Core specifically has a number of mechanisms that control connections:

It maintains a database (called &quot;addrman&quot;) with IP addresses (and Tor addresses, if that's in use) of known other Bitcoin nodes, together with some statistics and whether or not it has made a connection to it. New peers to connect to are drawn from this database. At most 10 connections are made, in order not to overload the network. This database is fed new information through:

Nodes gossip IP addresses of other nodes (the  addr P2P message) to each other.
A few DNS seeds are hardcoded that can be asked for more IP addresses if needed. This is only when not enough connections can be established after some time, and typically only needed the first time the client runs. After that, nodes autonomously find more peers to connect to.
As a very last resort, if DNS querying doesn't result in decent network connections, Bitcoin Core also has a list of hardcoded IP addresses to connect to.


The user can manually specify peers to connect to, using the connect= or addnode= configuration file options, or the addnode RPC command.
Nodes can accept incoming connections from other nodes too (there is a limit on this too; by default 125 connections, and when it's full some rules will prioritize peers from others).


how would nodes connect to the network without running bitcoin core?

Other implementations have their own mechanisms, but there is a wide spectrum - all the way from just connecting to the wallet provider's server, to learning about peers and connecting to them like Bitcoin Core does.

Supposed I wanted to write some code to develop my own bitcoin client. What was that code look like?

That really depends on what you want to do. There are libraries in many languages that implement the P2P protocol that lets you talk to other nodes, or you could start from scratch just following existing protocol documentation and Bitcoin Improvement Proposals (BIPs) that affect the P2P protocol. Remember, there is no authority in Bitcoin that can tell you exactly what &quot;the&quot; protocol is; proposals are made, and software dedvelopers implement them or don't. You'll want to test things, by not immediately dealing with the Bitcoin mainnet, but first try on the Bitcoin testnet or the newer &quot;signet&quot; test network.