connecting to servers
hi!
im trying to connect to a localhost server on my computer using java. the server is a java-program aswell, and both .java files are in the same folder. as of right now im just trying to get the server to print out a message "connected" in a new window just to se if it replies, but i cant get any message at all. the window opens but it is just blank, and it tells me that the applet has not started.
now, im not using a init(), istead im using a main(). im not really clear about the differens, but as i understand it you don磘 need an init() aslong as you dont care in which order stuff is giong to happen. as i only need the program to run once i chose the main() method, could that be it?
anyhow, heres my code, thankfull for any advice:
import java.net.*;
import java.io.*;
import java.util.*;
public class Client{
public static void main(String[] args){
try{
Socket socket = new Socket ("localhost", 1066);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter ut = new PrintWriter(socket.getOutputStream());
ut.println("Connected");
ut.flush();
System.out.println(in.readLine());
}
//ServerSocket sock = new ServerSocket(1066);
//while (true) new Trad(sock.accept()).start();
//}
//catch(IOException e){
//System.err.println(e);
}
}

