The newer USB 3.0 defines a way of having two hosts connect to one another. However, you need a specialized cable for this - not just any old USB cable with male/male connectors. Then most operating systems provide a means of running an EtherNet (i.e.normal network) across this, I know both Windows and Linux has this ability.
Other than that, it’s much simpler to rather just use a normal network instead. Plug a LAN cable between the two. Or set one as a WiFi hotspot. Or through a real network over a switch/router. It’s the major reason for having a network - sharing an internet connection is actually a by-product of this.
That said, there are programs which can force one computer to act as a client while the other acts as the host. Things like Laplink have been doing this for decades, even originally over serial cables instead of USB.
The problem with such 3rd party tools is that they tend to work through some proprietary protocol only their programs can “understand”. Thus it’s not a general purpose solution. E.g. your program cannot send data over it directly. It would need to save the data as a file and then use their program to send it. But if you use a real network, doing a data send/receive is a standard any program could use.





