View Single Post
Old Apr 19th, 2008, 6:44 PM   #4
Fall Back Son
Hobbyist Programmer
 
Join Date: Oct 2006
Posts: 203
Rep Power: 2 Fall Back Son is on a distinguished road
Re: Confused about simple multi-threaded server

I changed my code to the following, and now it appears to be working. However, I'm sure there's probably still something wrong with it... *sighs*

package stuff;
import java.net.*;
import java.io.*;

public class Client1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Socket echoSocket = null;
	     PrintWriter out = null;
	     BufferedReader in = null;
		try{
			int port = 1235;
			String hostname = "localhost";
			Socket connectionSock = new Socket(hostname, port);
			out = new PrintWriter(connectionSock.getOutputStream(), true);
	        in = new BufferedReader(new InputStreamReader(
	                                        connectionSock.getInputStream()));
			out.println("Print this message Mr. server");
			out.println("Print this other message Mr. server");
		}catch (Exception e){}
		
		
	}

}
Fall Back Son is offline   Reply With Quote