Hi,
i got really wierd problem here and can't solve it.
i wrote client/server programm in java everything works fine, (both sides in c\c++ also ok), i am trying to make java client to work with c server, but got very strange bug(well i don't know how to call it)
this is code from client
//...
is = new BufferedReader(new InputStreamReader(server.getInputStream()));
os = new PrintStream(server.getOutputStream());
String buffer = "name " + Login + " " +pswd;
// send first time
os.println(buffer+"\0");
String buffer1 = is.readLine();
String comm = getCommand(buffer1);
StringTokenizer st = new StringTokenizer(buffer1);
st.nextToken();
ID = st.nextToken();
if(comm.equals("accepted")){
println("Yout ID - "+ID); //everything is fine here
}
println("Repeat");
buffer = "name " + Login + " " +pswd;
println("send one more time "+buffer);
//send second time
os.println(buffer+"\0");
//this is for test purpose
while(true){
String buffer2 = is.readLine();
println("X "+buffer2);
if(buffer == "ad") break;
}
now i'll try to explain what results i get
after i send first time i get such string back(response to that string)
second time i send SAME thig to the server i get 3 strings
sometimes before accept i get some garbage. i checked the server, but it send only the data i need (wrote the answer string byte by byte into file)
so my question would be wtf is happenning here ??
i would be really glad if you helped me, because i have no idea where the problem could be.
thank you in advance.