Results 1 to 8 of 8
  1. #1
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default 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?

  2. #2
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    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.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Do a Search on the forum for Socket or client for many code samples.

  4. #4
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    Quote Originally Posted by chyrl View Post
    I think this tutorial will do, if you're going to use Socketing method to connect to the network.
    I know all this :)
    I just need to know how to send an int or a String without printing it on a console.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    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?

  6. #6
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    Quote Originally Posted by Norm View Post
    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?
    Ok I just know how to communicate with sending messages with this:

    Java Code:
    PrintStream os = null;
    os = new PrintStream(clientSocket.getOutputStream());
    os.println("Hello from the server ");
    How can I do it without the os.println(); but set it to a String in my client class so I can put it on JOptionPane.showMessageDialog(......);
    Last edited by PhQ; 07-24-2010 at 11:44 PM.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    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.

  8. #8
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    Quote Originally Posted by Norm View Post
    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.
    Aww NOO MORE TUTORIALS ?????
    Ok, thanks for your help, I will find some tutorials tomorrow, I'm going to sleep now.

Similar Threads

  1. Help with Networking
    By mr_anderson in forum Networking
    Replies: 1
    Last Post: 07-11-2010, 09:18 PM
  2. New to Networking
    By Psyclone in forum Networking
    Replies: 1
    Last Post: 03-06-2010, 01:49 AM
  3. Networking
    By Psyclone in forum AWT / Swing
    Replies: 1
    Last Post: 02-26-2010, 04:41 AM
  4. Networking Help
    By rp181 in forum Networking
    Replies: 4
    Last Post: 09-20-2009, 05:09 PM
  5. Networking in Java
    By thangavel14 in forum Networking
    Replies: 3
    Last Post: 07-30-2009, 01:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •