How to write data to a socket ?

Hello,

Can anyone give me a sample code for how to write data to a socket ?

What should I use a socket or a server socket ?

Please give me a sample code.

Thanks!

[192 byte] By [cratnama] at [2007-11-27 11:51:46]
# 1

did u try searching to forums before posting your question? You'd be surprised at how many people ask the EXACT same questions.

smithdale87a at 2007-7-29 18:40:20 > top of Java-index,Core,Core APIs...
# 2

Yes..I did...

I did not find what i wanted...

cratnama at 2007-7-29 18:40:20 > top of Java-index,Core,Core APIs...
# 3

> Can anyone give me a sample code for how to write

> data to a socket ?

theSocket.getOutputStream().write(97);

> What should I use a socket or a server socket ?

Use a Socket if you're writing a client, use a ServerSocket if you're writing a server.

> Please give me a sample code.

Reading a tutorial would be helpful before you start writing code, I think. Your Google search words should be "Java socket tutorial".

DrClapa at 2007-7-29 18:40:20 > top of Java-index,Core,Core APIs...
# 4

Thanq !

cratnama at 2007-7-29 18:40:20 > top of Java-index,Core,Core APIs...