Posts

Showing posts with the label udp

TCP Server failing after first response

TCP Server failing after first response NOTE I rewrote this question for the bounty as i was able to figure out how to get the first question solved but didn't want to start a new question. the comments below pertain to the original question, not the revised. Description of Issue My tcp client executes querying the tcp server one time successfully, returns the response, and then subsequent requests to the server from the client fails. Also, if i terminate the client and reload it fails on the first attempt as well. Here's what my command prompt looks like: root@ubuntuT:/home/jon/gocode/udps# ./udpservtcpclient Text to send: SampleQuery Message from server: SampleResponse Text to send: SampleQuery ((End - No Response)) root@ubuntuT:/home/jon/gocode/udps# ./udpservtcpclient Text to send: SampleQuery ((End - No Response)) What I expect I expect to be able to query the tcp server from the tcp client endlessly, and have the tcp server return a response from the UDP Server every tim...

How to receive multiple responses from UDP broadcast

How to receive multiple responses from UDP broadcast I have a case in which i need to send a broadcast a UDP request in the wifi on a specific port and the specific devices i am calling should return some info so i can determine how much are they in this network. So far i have this: public class UDP extends AsyncTask<Void, Void, String> { @Override protected String doInBackground(Void... voids) { String text = ""; int server_port = 7432; DatagramPacket receivePacket = null; DatagramSocket clientSocket = null; try { clientSocket = new DatagramSocket(); clientSocket.setSoTimeout(5); InetAddress IPAddress = InetAddress.getByName("255.255.255.255"); byte sendData = ("02904").getBytes(); byte receiveData = new byte[12]; DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, server_port); clientSo...