Results 1 to 2 of 2
  1. #1
    Lord Josh 1 is offline Member
    Join Date
    Feb 2011
    Rep Power

    Default New to Java Sockets

    Hey everyone,

    I'm want to setup a simple reader that outputs the information on a server when requested. For example, when I telnet to this server it automatically print's out, "Hello world!". Although when I made a simple Java socket connector, it doesn't print anything. What I want to achieve, in the long term, is being able to read and write to this server.

    Here is the code that I'm using:

    Java Code:
    public void connect() throws IOException{
    		String host = "";
    		int port = 6112;
    		Socket socket = new Socket(host, port);
    		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream( )));
    		BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream( )));
    How would I get it to output whatever comes from the server, then write something else to the server? :)

  2. #2
    glauber is offline Member
    Join Date
    Feb 2011
    São José dos Campos, Brazil
    Rep Power


    I've also started to deal with sockets in the past week. There's plenty of tutorials/examples online. Try this one.

Similar Threads

  1. voice chat in java with sockets
    By krati in forum Networking
    Replies: 0
    Last Post: 05-12-2010, 09:17 AM
  2. Java Sockets
    By PhQ in forum New To Java
    Replies: 2
    Last Post: 05-07-2010, 11:34 AM
  3. Request-Reply With Java Sockets
    By grassbl8d in forum Networking
    Replies: 0
    Last Post: 03-03-2010, 06:11 PM
  4. Java sockets
    By Camzie in forum NetBeans
    Replies: 3
    Last Post: 12-22-2009, 04:39 PM
  5. Java application using sockets!
    By rameshraj in forum Threads and Synchronization
    Replies: 1
    Last Post: 06-11-2008, 06:13 PM

Posting Permissions

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