Sajal
Sajal

Reputation: 1853

Is it possible to establish socket communication between Windows 7 and Linux machine over LAN?

I have connected a Linux machine and a Windows machine via LAN cable. Both machines are not connected to any network. Is it possible to establish a socket communication between these machine? If yes, how?

Upvotes: 2

Views: 107

Answers (2)

u354356007
u354356007

Reputation: 3215

For sure it's possible! Here's a checklist of what you should do:

  1. Connect the machines with a cable. Any Ethernet cable would be fine.
  2. Set up a LAN between two machines: pick a subnet from one of the three IPv4 private address spaces. Pick two IP addresses A and B. Assign IP A to the first machine* and set up a default gateway to B. On the second machine, assign IP address B and specify A as a default gateway.
  3. Make changes to firewalls on your machines (it's mostly a windows issue).
  4. Try to ping another machine.
  5. Once you can ping, nothing stops you from using sockets.

\Strictly speaking, you don't assign an IP address to the whole machine: you assign an address to the interface where you plugged in an ethernet cable.

Upvotes: 1

Alexandre Fenyo
Alexandre Fenyo

Reputation: 4809

Since you have not any network, only two hosts one connected to the other (that is in fact a network, a very small network), you do not have a DHCP server. So, your hosts are automatically configured with IPs in the range 169.254.0.0 to 169.254.255.255, you do not have to configure anything at the network level. Now, you can use socket programming to exchange data between those hosts, using their IP addresses. Use ifconfig on the Linux host and ipconfig on the Windows one to get the addresses and insert them in you programs, or give them as a parameter.

Upvotes: 0

Related Questions