开发者

C# - Communicate between two laptops that are not connected to a LAN

开发者 https://www.devze.com 2023-02-12 21:45 出处:网络
I need to communicate (in C#) between two (or more) laptop computers that are not on a LAN. Here is the scenario: A couple of agents (with laptops) go from region to region working in several offices

I need to communicate (in C#) between two (or more) laptop computers that are not on a LAN.

Here is the scenario: A couple of agents (with laptops) go from region to region working in several offices (at the same time).

I need a way for the agents to be able to share and merge files with each other without having to resort to emailing, copying to USB drives and checking-in the files to the central repository.

What will be the best (easiest/secure) way to archive this? B开发者_JAVA技巧luetooth, AdHoc Mode, Wifi!


If they're not on a LAN, presumably you can connect them together directly using an Ethernet cable.

  • Most/all modern machines support 'auto-mdix', so you shouldn't need a crossover cable, but if you're in any doubt, then using a crossover cable won't hurt.
  • If they're set to use DHCP normally, then they'll auto-address themselves after a short delay without finding a DHCP server. (Or turn on IPv6, which will do all that properly.)
  • If you make sure file and printer sharing is turned on on both machines (and the appropriate firewall exception enabled), then netbios name discovery will work without a DNS server present, so they'll be able to address each other by machine name.


Since they are not connected to a LAN, I kind of assume they are also not connected to a wifi access point, since if they were they would be connected to a LAN (a WLAN). Wifi ad hoc mode is easy to setup, just configure both interfaces as a computer to computer network, and manually set their IP addresses to something like 192.168.1.1 and 192.168.1.2 with netmask 255.255.255.0. After this, all you need to do is open a socket connection in C# between them, say 192.168.1.1 opens a socket to 192.168.1.2.

For simplicity, you could also install a DHCP server on one of them, and you would then only need to configure the IP address on one machine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号