Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #12753
| From | Knute Johnson <nospam@knutejohnson.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How to receive and send websocket messages in Java? |
| Date | 2012-03-07 14:24 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <jj8n6j$c0e$1@dont-email.me> (permalink) |
| References | <31969353.4397.1331150560621.JavaMail.geo-discussion-forums@vbtv42> <24681763.594.1331155027592.JavaMail.geo-discussion-forums@pbcsl10> <4309843.3.1331158120887.JavaMail.geo-discussion-forums@vblo18> |
On 3/7/2012 2:08 PM, Mihael wrote:
> Thanks for your answer! But i can't understand, how to decode БУЭѓчЮ’ ЫттПДсюƒТкљ№Тмл Е ?
>
> When I send "1" i get string ББђ,¶3Э
> or send "ping" i get string БДЧ≤’4зџїS
> or send "hello world!" i get string БМяЩрЈfхЬ∞#оЯ≠oэ—
>
> this is special encoded websocket strings? or what?
>
> pseudo code is
>
> InputStream is = s.getInputStream();
> byte buf[] = new byte[64*1024];
> int r = is.read(buf);
> String data = new String(buf, 0, r);
> System.out.println("Recieved Data: " + data);
If you are going to send Strings, you don't want to read and write bytes.
BufferedReader br = new BufferedReader(new InputStreamReader(
s.getInputStream(),***YOUR CHAR SET GOES HERE***));
br.readLine();
If the server you are connecting to is using a different character set
you need to use a different constructor for InputStreamReader that sets
the character set. See the docs for InputStreamReader.
--
Knute Johnson
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar
How to receive and send websocket messages in Java? Mihael <isaev.mihael@gmail.com> - 2012-03-07 12:02 -0800
Re: How to receive and send websocket messages in Java? Mihael <isaev.mihael@gmail.com> - 2012-03-07 12:03 -0800
Re: How to receive and send websocket messages in Java? Lew <lewbloch@gmail.com> - 2012-03-07 13:17 -0800
Re: How to receive and send websocket messages in Java? Mihael <isaev.mihael@gmail.com> - 2012-03-07 14:08 -0800
Re: How to receive and send websocket messages in Java? Knute Johnson <nospam@knutejohnson.com> - 2012-03-07 14:24 -0800
csiph-web