• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java client/ c server problem

Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

String buffer1 = is.readLine();

String comm = getCommand(buffer1);
StringTokenizer st = new StringTokenizer(buffer1);
ID = st.nextToken();
println("Yout ID - "+ID); //everything is fine here


buffer = "name " + Login + " " +pswd;
println("send one more time "+buffer);
//send second time
//this is for test purpose
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic