hi all,
this is my program ...... By this need to change my port again and again .....
will you help me to proper closing of socket......
code:
<%!
ServerSocket MyServer;
Socket Mysocket;
File file = new File("file.txt" );
FileInputStream fis = null;
BufferedInputSt ream bis = null;
DataInputStream dis = null;
DataOutputStrea m dos=null;
%>
<%
int port = Integer.parseIn t(request.getPa rameter("port1" ));
try{
MyServer = new ServerSocket(po rt);
Mysocket = MyServer.accept ();
fis = new FileInputStream (file);
bis = new BufferedInputSt ream(fis);
dis = new DataInputStream (bis);
dos = new DataOutputStrea m(Mysocket.getO utputStream());
while (dis.available( ) != 0)
{
dos.writeBytes( dis.readLine()) ;
}
fis.close();
bis.close();
dis.close();
dos.flush();
dos.close();
Mysocket.close( );
MyServer.close( );
}
catch(Exception e)
{
System.out.prin tln("Encountere d an error!!!!"+e);
}
%>
End of code:
this is my program ...... By this need to change my port again and again .....
will you help me to proper closing of socket......
code:
<%!
ServerSocket MyServer;
Socket Mysocket;
File file = new File("file.txt" );
FileInputStream fis = null;
BufferedInputSt ream bis = null;
DataInputStream dis = null;
DataOutputStrea m dos=null;
%>
<%
int port = Integer.parseIn t(request.getPa rameter("port1" ));
try{
MyServer = new ServerSocket(po rt);
Mysocket = MyServer.accept ();
fis = new FileInputStream (file);
bis = new BufferedInputSt ream(fis);
dis = new DataInputStream (bis);
dos = new DataOutputStrea m(Mysocket.getO utputStream());
while (dis.available( ) != 0)
{
dos.writeBytes( dis.readLine()) ;
}
fis.close();
bis.close();
dis.close();
dos.flush();
dos.close();
Mysocket.close( );
MyServer.close( );
}
catch(Exception e)
{
System.out.prin tln("Encountere d an error!!!!"+e);
}
%>
End of code:
Comment