• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

get replay from server ?

KorenRon

Lurker
Hello ,
I hava an application that send string to my server using udp
now I want the server to return an answer

what do I need to define in the application ?
do I need to change the sending to TCP and not UDP? so the server can return the answer?

Thanks,
 
What sort of reply are you looking for? You're going to have to have something on the server that is looking for your message so it can send a reply.
 
this is what I have now:
I'm sending UDP from the application to the server
the server is listening , when he get message he check if the string is OK (no spelling mistake) according to my setting
in the server side - if there is a problem in the string I get an exception
I want to be able to send this exception also to the application , so the user will also know there is a problem

example :
APP sending: "A12345A"
Server : string is OK - send to APP "OK

APP sending "A12A"
Server : string is not OK , Send to APP "bad message!,check";

Thanks,
 
I have setup a simple tcp_server on C#
and this is what I have found in java for tcp_client :

import java.io.*;
import java.net.*;

class TCPClient {
public static void main(String argv[]) throws Exception {
String sentence;
String modifiedSentence;
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
sentence = inFromUser.readLine();
outToServer.writeBytes(sentence + 'n');
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
clientSocket.close();
}
}

will this work?
or do I need to add something else?

Thanks ,
 
I would test the server independently, not via the app, to be sure it's returning the expected responses. Once you have that working, then integrate the app.
 
Back
Top Bottom