Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

java client/ c server problem

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
You didn't tell me he was so big. Unlike this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic