CS401 | sw engineering
  • outline
  • projects
  • syllabus
  • links

  Use of Java Server

EXAMPLE CODE

Multithreading Java server Server.java

 

     

  • listens on port 50001

     

  • accepts connections

     

  • creates concurrent threads to service them

 

Each concurrent thread

 

     

  • reads filename from socket

     

  • opens file of that name

     

  • writes contents of file down socket

     

  • closes file and socket

 

Start server on host ebox in directory with big file data.txt

 

    minerva% java Server

 

Establish socket connection from Client 1 to server using telnet

 

    castor% telnet ebox 50001
    ...

 

Establish socket connection from Client 2 to server using telnet

 

    pollux% telnet ebox 50001
    ...

 

Quickly enter data.txt in terminal windows on Client 1 and Client 2.

Contents of file should be listed concurrently in both windows.

cs401:sw engieering

  • home
  • outline
  • projects
  • syllabus
  • links