Results 1 to 2 of 2
Thread: New to Java Sockets
- 02-15-2011, 04:08 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
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 = "172.16.0.118"; 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( ))); while(true){ System.out.println(reader); } }
- 02-15-2011, 04:38 PM #2
Member
- Join Date
- Feb 2011
- Location
- São José dos Campos, Brazil
- Posts
- 6
- Rep Power
- 0
I've also started to deal with sockets in the past week. There's plenty of tutorials/examples online. Try this one.
Similar Threads
-
voice chat in java with sockets
By krati in forum NetworkingReplies: 0Last Post: 05-12-2010, 09:17 AM -
Java Sockets
By PhQ in forum New To JavaReplies: 2Last Post: 05-07-2010, 11:34 AM -
Request-Reply With Java Sockets
By grassbl8d in forum NetworkingReplies: 0Last Post: 03-03-2010, 06:11 PM -
Java sockets
By Camzie in forum NetBeansReplies: 3Last Post: 12-22-2009, 04:39 PM -
Java application using sockets!
By rameshraj in forum Threads and SynchronizationReplies: 1Last Post: 06-11-2008, 06:13 PM
Bookmarks