Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

simple socket program not working right

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

whats wrong with this code.message is send to server and reaches there but it's not send back to the client.server hangs
if the clietn doesn't read the stream it works else it doesn't.tell the error in the code .try it out please.
I added the UBB tag CODE to allow easier reading
[This message has been edited by Carl Trusiak (edited January 27, 2001).]
[This message has been edited by Carl Trusiak (edited January 27, 2001).]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two things jump out.
strt=is.readLine();
System.out.println(strt);
os.writeChars(str);
You are trying to read the response from the Server Before you send the message! Change this to
os.writeChars(str);
strt=is.readLine();
System.out.println(strt);
And the message will be sent to the server. This is the first thing. The second
os.writeChars(str);
Doesn't send an end of line character. Using the streams you are using, you need to specifically send an end of line
os.writeChars(str);
os.write(10);
This will complete the communications. Once you see this, you may want to rethink the streams you are using to allow cleaner communications.

------------------
Hope This Helps:)
Carl Trusiak
 
reply
    Bookmark Topic Watch Topic
  • New Topic