• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Server and Client communication probs

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)I have written a SocketServer on one machine which
a.Waits for a connection from a client
b.Sends a message to the client using a PrintWriter
c.Receives a message from the client using a BufferedReader
2)On another machine I have a client program which
a.Creates a connection with the server
b.Receives the message from the server using a BufferedReader
c.Sends a message to the server using a PrintWriter
My intention was for the tasks executed in the following order:-
1a,2a,1b,2b,2c,1c
Instead, when run the following happens
1a,2a
And then the client stalls (blocking I think).
The following scenarios were tried to ascertain the problem (but to no avail)
A)If I keep the server code the same but comment out step 2b from the client code, the following happens (with 1b, 2b missing)
1a,2a,2c,1c
B) If I keep the server code the same but comment out step 2a from the client code the following happens (with 1c, 2c missing)
1a,2a,1b,2b
C)Keeping the client code the same but comment out step 1b from the server code only following occurs, (with 1b, 1c, 2b, 2c missing)
1a,2a
D)Keeping the client code the same but commenting out step 1c from server results in 1c missing ie
1a,2a,1b,2b,2c

What is the problem? It seems like there is blocking going on somewhere. Is it not possible for a server and client to communicate backwards and forwards?
If necessary, please mention and I will post the code.
Thanks in advance,
 
Con Lu
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add that the question above is regarding pre-1.4 code.
Thanks
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried flushing the PrintWriters after each write?
 
Con Lu
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have already flushed the PrintWriter. Please see code below:-


// CLIENT CLASS CODE

[ June 13, 2003: Message edited by: Michael Morris ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic