varunjithtk22
Posts: 3
Joined: Thu Jan 23, 2014 5:59 pm

Talk to pi with shared internet from another laptop

Thu Jan 23, 2014 6:32 pm

I am learning socket programming using python
I have two laptops ( say A and B) connected to same WiFi. A pi is connected to A via Ethernet cable and sharing internet.
A has IP address 192.168.0.100 B has IP 192.168.0.101
A has Ethernet interface IP add 169.254.1.220
Pi has Ethernet interface IP add 169.254.1.230

Now, if I run server on A binding to 192.168.0.100 my client in B can talk to it and communicate , but
if I run server on pi binding to 169.254.1.230 my client in B cannot establish a connection. I don't know the reason behind this.Is 169... in some private/hidden LAN ? How make Pi and B communicate?

Thanks in advance

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Talk to pi with shared internet from another laptop

Thu Jan 23, 2014 10:30 pm

Bind your servers to inaddr_any (0.0.0.0) and most of your problems evaporate.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

varunjithtk22
Posts: 3
Joined: Thu Jan 23, 2014 5:59 pm

Re: Talk to pi with shared internet from another laptop

Fri Jan 24, 2014 4:40 pm

Sorry , still same problem ..
I also tried socket.bind("", port). When trying to connect on client side i get this

Traceback (most recent call last):
File "/home/xxx/yyyy/Tech/raspberryPi_Lnx/code/new.py", line 10, in <module>
s.connect((host, port))
socket.error: [Errno 113] No route to host
>>>

My pi address is 169.254.226.230 , Laptop which is connected to pi over LAN is 192.168.0.100..... remote laptop over same wifi is 192.168.0.101.
Also when I ping pi from remote laptop i get not reachable( will this give any clue)

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Talk to pi with shared internet from another laptop

Fri Jan 24, 2014 4:54 pm

I think this is a network routing/NAT problem. When you use ICS on the PC (A) it acts as a NAT router, so any traffic from the "inside" (Pi) will get the PCs ip-address and no-one else knows about 169.x.x.x adresses.

also...

When the other PC (B) tries to connect to the Pi it sees that 169.x.x.x is not on the same sub-net so it sends it to the standard gateway. Which is most likely your wifi/adsl-router (192.168.0.1 I would guess), this router doesn't know what to do with that address either so it may send it out on the internet or just reject it (no route to host).

You might have some chance if you create a static route on B that tells it to use A as a gateway for the traffic going to 169.x.x.x adresses. Google for the method for your OS.

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Talk to pi with shared internet from another laptop

Fri Jan 24, 2014 10:11 pm

varunjithtk22 wrote:Sorry , still same problem ..
I also tried socket.bind("", port). When trying to connect on client side i get this

Traceback (most recent call last):
File "/home/xxx/yyyy/Tech/raspberryPi_Lnx/code/new.py", line 10, in <module>
s.connect((host, port))
socket.error: [Errno 113] No route to host
>>>

My pi address is 169.254.226.230 , Laptop which is connected to pi over LAN is 192.168.0.100..... remote laptop over same wifi is 192.168.0.101.
Also when I ping pi from remote laptop i get not reachable( will this give any clue)
Try this:

Code: Select all

import socket

HOST = "0.0.0.0"
#HOST = socket.gethostname()
PORT = 51234

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen()
... 
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Networking and servers”