Main Site Documentation

Tcp socket Connect


I have a network related problem and need help to understand how TCP/IP based networks work.

I have a computer with two network card. One with the following IP, the second with

I have an application that send a broadcast udp message over the network.

I have an EMX based module connected to the second card of the computer. its adress is

When I launch the application the udp broadcast message is seen by the EMX board. The EMX then should establish a connection to a remote host on

tcpsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint ServerEndPoint = new IPEndPoint(DestinationIP, 47001);

The problem is that connect blocks. This does not happened if I connect the EMX to the first network card of the computer. What is wrong?


What’s the value of DestinationIP?
If EMX is connected to NW Card 2 it should be


@ leforban - If you have your network configured for different Class C Subnets, you will need an appropriate netmask to match. For this you can use


@ leforban - For the EMX to send to the other network, the PC has to act as a gateway/router, which is not the normal situation. I think if you play with Internet sharing you might be able to get it to work.


As mentioned the issue you’re likely to hit first is routing. But the piece of information we’re missing is subnet masks and default gateway settings on each device, to make sure that a broadcast isn’t going to be doing funny things.

I would actually suspect though that your PC-based application is not responding on the network card that the EMX is connected to. Does this app explicitly target the 192.168.2.x network ? If not, then it’s probably just listening on the default network and because there is no active routing going on, it never sees the connection request from the EMX.

The simplest way to really test what is going on is to use a 2nd PC and a dumb network hub, connect the EMX to the hub, connect the 192.168.2.x network card to the hub, and the 2nd PC to the hub and run network monitor / wireshark and capture the interactions. Another way, but one that may be more complex, is to do it from your PC and target the 192.168.2.x network interface.

Is this just a testing scenario, or one you expect to be longer term?