Hi,
I have a byte[] that is my message.
How can I sent it by TCP protocol?
What kind of output stream have I use?
Thanks
palmis
garyD - 13 Jan 2006 13:21 GMT
Look at java.net.URL for information on connecting to another computer
via TCP/IP. If you want to send the byte[] to a servlet or JSP, you
could use java.io.ObjectOutputStream.
palmis - 13 Jan 2006 13:27 GMT
Dear garyD,
I want to send byte[] to another computer (TCP client).
I have find some java commands but I don't know the kind of Output
stream that I have to use for sending.
Thanks
Palmis.
Gordon Beaton - 13 Jan 2006 13:39 GMT
> I want to send byte[] to another computer (TCP client). I have find
> some java commands but I don't know the kind of Output stream that I
> have to use for sending.
To send and receive byte data, use a plain or buffered OutputStream
and InputStream.
There is an overview of the various stream types here:
http://java.sun.com/docs/books/tutorial/essential/io/overview.html
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Thomas Fritsch - 13 Jan 2006 13:42 GMT
> I have a byte[] that is my message.
> How can I sent it by TCP protocol?
> What kind of output stream have I use?
Class java.net.Socket has a getOutputStream() method. Therefore you can
just use that OutputStream without knowing what kind of OutputStream it
actually is:
Socket socket = new Socket(host, port);
OutputStream os = socket.getOutputStream();
byte message[] = ....;
os.write(message);

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Roedy Green - 14 Jan 2006 05:12 GMT
>I have a byte[] that is my message.
>How can I sent it by TCP protocol?
>What kind of output stream have I use?
See http://mindprod.com/applets/fileio.html
tell it you want to write raw bytes to a socket.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Hiran Chaudhuri - 20 Jan 2006 06:25 GMT
> Hi,
> I have a byte[] that is my message.
> How can I sent it by TCP protocol?
> What kind of output stream have I use?
Have a look at java.net.Socket.
Hiran Chaudhuri