wood burning stoves*
The moose likes Sockets and Internet Protocols and the fly likes client->server : data flow prob. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "client->server : data flow prob." Watch "client->server : data flow prob." New topic
Author

client->server : data flow prob.

Harish Kashyap
Ranch Hand

Joined: Jun 14, 2000
Posts: 118

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
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client->server : data flow prob.
 
Similar Threads
XML over HTTP embedded server problems
default character set seems not work in my jboss environment
One month Extra get added during method call in java.
Problem Whit Special Characters on server side
clientID