The first step is to try and hardcode the ip of the other computer and test. If that works then look at adding UDP Broadcast Discovery. Here's an example in java: http://michieldemey.be/blog/network-discovery-using-udp-broadcast/
The idea is that all devices that need to talk broadcast on UDP. Once they hear the broadcast, they need to connect to eachother. Usually one side will need to be pre-determined as the server, and the other as the client.