Document transfer (server can respond multiple requests) - DOSY

xiaoxiao2021-03-06  13

Import java.io. *;

Import java.util. *;

Import java.net. *;

Class Serone Extends thread {

PRIVATE SOCKET SER;

File INPUTFILE = New File ("dos.csf");

Public serone (socket s) {

THIS.SER = S;

}

Public void run () {

Try {

BufferedInputStream in = New BufferedInputStream (New FileInputStream (InputFile);

Bufferedoutputstream OU = New BufferedOutputStream ((Ser.getputStream ())));

INT C;

While ((c = in.read ())! = - 1)

Ou.write (c);

In.Close ();

Ou.close ();

} catch (exception e) {

System.out.println (E.TOString ());

}

}

}

Public class test {

Public static void main (string [] args) throws exception {

Serversocket S = New Serversocket (12312);

Try {

While (true) {

Try {

Socket Ser = S.Accept ();

System.out.Println ("Connection Already .....");

NEW Serone (SER). START ();

//tt.start ();

}

Catch (IOException E) {

//ser.close ();

System.err.println (e.tostring ());

}

}

}

Finally {

s.close ();

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-49733.html

New Post(0)