Skip to content
Advertisement

TCP client cannot connect to TCP server

I have configured a Raspberry Pi to be client, and my personal computer to be TCP server, and trying to connect to server via an ethernet cable. On my personal computer I use Comm Operator and select port “1234”. Raspberry Pi (TCP client) has following setup:

auto eth0
iface eth0 inet static
  address 192.168.20.45
  netmask 255.255.255.0
  gateway 192.168.20.1

Raspberry Pi (TCP client) has the following script to connect:

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('192.168.20.48',1234))

And frankly, it get stuck in the connect step, doesnt even get past that. On the TCP server side running on Windows, IPv4 setup is as follows:

192.168.20.48
255.255.255.0
192.168.20.1

with Google DNS

8.8.8.8
8.8.4.4

Weird thing is that it works the other way around, if I set up my computer as client and connect to raspberry pi. Could you give me some ideas as to what could be the problem? I really could use some opinion. Thanks in advance to everyone.

Advertisement

Answer

You probably have a firewall running on your computer. Disable it or open up the desired port.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement