• 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

client->server : data flow prob.

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

hi friends!
i have a problem.
i'm creating a client-server aplication. client is an applet and server is an application.
on the client side i send some message to server using writeChars() method of DataOutputStream and reading it on server side using readLine() method. and same vice versa.

now my problem is that the string i'm recieving is same as sent by other end but its size is doubled(i.e. no. of characters)
while printing it on the console it gives the same string.
the only problem is that it inserts a null character between each two characters of the string.
i'm working on linux platform.
please suggest some solution.
thanx
harish
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the J2SE:
writeChar(int): Writes a char to the underlying output stream as a 2-byte value, high byte first.
writeChars(String) simply runs the writeChar(int) method as many times as the length of the String.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Harish Kashyap:

hi friends!
i have a problem.
i'm creating a client-server aplication. client is an applet and server is an application.
on the client side i send some message to server using writeChars() method of DataOutputStream and reading it on server side using readLine() method. and same vice versa.

now my problem is that the string i'm recieving is same as sent by other end but its size is doubled(i.e. no. of characters)
while printing it on the console it gives the same string.
the only problem is that it inserts a null character between each two characters of the string.
i'm working on linux platform.
please suggest some solution.
thanx
harish


The string you are receiving is UNICODE representation..two bytes per character, which would appear to Linux to be (null + ASCII) representation. By using OutputStreamWriter and specifying "latin1" encoding, you can send string as ASCII.
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic