Results 1 to 8 of 8
Thread: New to networking
- 07-24-2010, 10:00 PM #1
New to networking
Hey people I am totally new to JAVA networking. I have learned how to send messages to the client and server and how to run multiple clients.
My question is how can I send ints or Strings from the client to the server?
I am going to try to make like a little game, where you can walk around with squares - is there any examples for this?
- 07-24-2010, 10:45 PM #2Senior Member
- Join Date
- Mar 2010
- Manila, Philippines
- Rep Power
I think this tutorial will do, if you're going to use Socketing method to connect to the network.Every project, package, class, method, variable, syntax, algorithm, etc.
are registered in my memory bank. Thanks to this thread.
- 07-24-2010, 11:00 PM #3
Do a Search on the forum for Socket or client for many code samples.
- 07-24-2010, 11:36 PM #4
- 07-24-2010, 11:39 PM #5
Wrap the output stream in a DataOutputStream. That class has methods for writing many different types of data.
I'm not sure what "without printing it on a console" means here?
- 07-24-2010, 11:42 PM #6
PrintStream os = null; os = new PrintStream(clientSocket.getOutputStream()); os.println("Hello from the server ");
Last edited by PhQ; 07-24-2010 at 11:44 PM.
- 07-24-2010, 11:49 PM #7
Looks like its time to read some more tutorials. Read how to use the DataOutputStream class.
Your example wrapped the output stream in a PrintStream.
Wrap it with DataOutputStream instead.
The other side will have to wrap its input stream in the DataInputStream to be able to read the data. The data must be read in the same order as it was sent.
- 07-24-2010, 11:56 PM #8
- By mr_anderson in forum NetworkingReplies: 1Last Post: 07-11-2010, 09:18 PM
- By Psyclone in forum NetworkingReplies: 1Last Post: 03-06-2010, 01:49 AM
- By Psyclone in forum AWT / SwingReplies: 1Last Post: 02-26-2010, 04:41 AM
- By rp181 in forum NetworkingReplies: 4Last Post: 09-20-2009, 05:09 PM
- By thangavel14 in forum NetworkingReplies: 3Last Post: 07-30-2009, 01:47 AM