Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

sent byte[] by TCP

Thread view: 
palmis - 13 Jan 2006 12:23 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?

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.