Hello friends, actually i have a problem with following programs:
First:---------
import java.net.*;
import java.io.*;
public class SimpleServer{
public static void main(String[] a){
ServerSocket s=null;
try{
s=new ServerSocket(54 32);
}catch(IOExcept ion e){
e.printStackTra ce();
}
while(true){
try{
Socket s1=s.accept();
OutputStream s1out=s1.getOut putStream();
BufferedWriter bw=new BufferedWriter( new OutputStreamWri ter(s1out));
bw.write("Hello Net World!!");
bw.close();
s1.close();
}catch(IOExcept ion e){
e.printStackTra ce();
}
}
}
}
Second:----------
import java.net.*;
import java.io.*;
public class SimpleClient {
public static void main(String[] a) {
try
{
Socket s1 = new Socket("127.0.0 .1", 5432);
InputStream is = s1.getInputStre am();
DataInputStream dis = new DataInputStream (is);
System.out.prin tln(dis.readUTF ());
br.close();
s1.close();
}
catch (ConnectExcepti on con)
{
System.err.prin tln("Coult not connect");
}
catch (IOException ex)
{
//ex.printStackTr ace();
}
}
}
when i compile and run these programs in two different cmd windows nothing is shown as output, pls help!!
First:---------
import java.net.*;
import java.io.*;
public class SimpleServer{
public static void main(String[] a){
ServerSocket s=null;
try{
s=new ServerSocket(54 32);
}catch(IOExcept ion e){
e.printStackTra ce();
}
while(true){
try{
Socket s1=s.accept();
OutputStream s1out=s1.getOut putStream();
BufferedWriter bw=new BufferedWriter( new OutputStreamWri ter(s1out));
bw.write("Hello Net World!!");
bw.close();
s1.close();
}catch(IOExcept ion e){
e.printStackTra ce();
}
}
}
}
Second:----------
import java.net.*;
import java.io.*;
public class SimpleClient {
public static void main(String[] a) {
try
{
Socket s1 = new Socket("127.0.0 .1", 5432);
InputStream is = s1.getInputStre am();
DataInputStream dis = new DataInputStream (is);
System.out.prin tln(dis.readUTF ());
br.close();
s1.close();
}
catch (ConnectExcepti on con)
{
System.err.prin tln("Coult not connect");
}
catch (IOException ex)
{
//ex.printStackTr ace();
}
}
}
when i compile and run these programs in two different cmd windows nothing is shown as output, pls help!!
Comment