Connection issue to new Samsung S9

I have a new Samsung Galaxy S9 which replaces a Samsung Galaxy S6 and I have two issues which are probably connected:

a) I cannot use the App "Wifi File Transfer Pro" - when I launch the App on the phone it gives an IP address to enter into my browser on the PC, but when I enter this address it will not bring up the page - the connection eventually times out; on the Galaxy S6 this works perfectly

b) I have an app I have written in Java which has components running on the phone and my PC, which I use for transferring various files between the phone and my PC - again this has worked perfectly for many years on the Galaxy S6, but on the S9 it fails to connect:  the phone component successfully wakes up the PC component which does its thing and then tries to connect to send the result, but the java command connection=new Socket(host, PORT) times out with the error message " Connection timed out: connect"

It looks like a firewall issue, but it's not the firewall on my PC since I've tried disabling that temporarily.   It may be a firewall issue on the Samsung S9 but I can't see how to configure that.   I've tried tweaking the Setting "Phone visibility" but that doesn't seem to solve the issue.

Any thoughts?
Who is Participating?
DavidRMasonConnect With a Mentor Author Commented:
Further to this - I cleaned the code and restarted and it now works.  

The solultion was to add the line:

fred hakimRetired ITCommented:
I have a galaxy s8active and I noted it now requires me to tap allow on the phone for access to data, when i connect with my PC.  It might also be some security hoop for your method of connecting as well.  There might be a setting somewhere to turn these  off.
DavidRMasonAuthor Commented:
Fred  - thanks for the comment.   I too get a prompt when I have a wired connection, but these are connecting via Wifi.   There might indeed be a setting somewhere - I hope there is - but I've had a thorough look and can't find anything that looks relevant.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

DavidRMasonAuthor Commented:
Further to my question, I've attached the new device to my PC in developer mode using ADB and identified that the program stalls in the following lines of code running on the phone:
                                       DatagramSocket socket=new DatagramSocket();
                              byte[] data=(requestCode+androidid).getBytes();
                              DatagramPacket packet=new DatagramPacket(data,data.length,broadcastAddress,datagramPort);
                              byte[] reply=new byte[MAX_SIZE];
                              DatagramPacket replyPacket=new DatagramPacket(reply,reply.length);
The program successfully executes the socket.send command but never returns from the socket.receive command - thus something is blocking the reply packet.   On my old phone this code has been running trouble free for many months.   I've confirmed on the PC side that the packet sent is successfully received.
DavidRMasonAuthor Commented:
I found this article: which looks relevant

Adding the line socket.setBroadcast(true) enables the code to progress beyond the stage above and establish basic datagram connectivity, which my program uses to find the server and exchange basic information to enable the connection for file transfer to be established.

There must be something similar to enable the file transfer to work, but still looking.
fred hakimRetired ITCommented:
glad to hear that, I hadn't been able to find much to help you.
DavidRMasonAuthor Commented:
Finding the right search in Google to locate the relevant article - the key was to determine that the source of the problem was inability to send a datagram and including the word "datagram" in the search.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.