sent byte[] by TCP

P

palmis

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
 
G

garyD

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.
 
P

palmis

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.
 
T

Thomas Fritsch

palmis said:
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);
 
H

Hiran Chaudhuri

palmis said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top