This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Server cannot show string  RSS feed

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.

i recreate a server program in my pc that can read any input (string) from client(android) which is transmitted via bluetooth (kinda like bluetooth chat). The problem is my server seems cannot show string immediately after i send it from my client, it'll only appeared after i turn off the bluetooth and the connection was cut, also it won't send response string to client. already try to put pWriter.flush() to make string shows, but it doesn't works. can you tell me what's wrong with my program? thank you.

here is my program :



 
Bartender
Posts: 3321
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the client code as well please and does it use flush() as well.
 
nida azizah
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i though it'll be different when i'm programming using android studio so i'm not using flush();. do i have to use it too? sorry, i am new to java.

here's my code in client to read and write my string:



Thanks for your help.
 
Tony Docherty
Bartender
Posts: 3321
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I've never programmed for android so I can't give you a definitive answer to that but I would have thought you would have needed to call flush().
 
nida azizah
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the problem is occurred on my server sides because i already change my client program several times but the result on server is still same. do you have any idea or some suggestions regarding my server sides?
 
Tony Docherty
Bartender
Posts: 3321
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with not calling flush() in the client code (assuming the android stuff works the same as standard Java) is the client is unlikely to send the string until the connection is being closed (or the buffer fills up) so the server will just sit there waiting for the message from the client.
 
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To help determine if it is a client-side problem or a server-side problem, try using a running an Android Bluetooth terminal emulator client, and see if the behaviour on the server changes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!