Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
18
Task/Echo-server/Haskell/echo-server-2.hs
Normal file
18
Task/Echo-server/Haskell/echo-server-2.hs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
global mlck, nCons
|
||||
|
||||
procedure main()
|
||||
mlck := mutex()
|
||||
nCons := 0
|
||||
while f := open(":12321","na") do {
|
||||
handle_client(f)
|
||||
critical mlck: if nCons <= 0 then close(f)
|
||||
}
|
||||
end
|
||||
|
||||
procedure handle_client(f)
|
||||
critical mlck: nCons +:= 1
|
||||
thread {
|
||||
select(f,1000) & repeat writes(f,reads(f))
|
||||
critical mlck: nCons -:= 1
|
||||
}
|
||||
end
|
||||
|
|
@ -56,7 +56,7 @@ class ClientHandler implements Runnable {
|
|||
String inputLine, outputLine;
|
||||
while((inputLine = in.readLine()) != null){
|
||||
outputLine = inputLine;
|
||||
System.out.println("recieved: " + outputLine);
|
||||
System.out.println("received: " + outputLine);
|
||||
out.write(outputLine+"\n");
|
||||
out.flush();
|
||||
if (outputLine.equals("exit"))
|
||||
|
|
|
|||
|
|
@ -29,5 +29,5 @@ Inherits ConsoleApplication
|
|||
DoEvents() 'pump the event loop
|
||||
Wend
|
||||
End Function
|
||||
Private Listener As EchoListener
|
||||
Private Listener As EchoServer
|
||||
End Class
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue