Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Echo-server/Julia/echo-server.julia
Normal file
23
Task/Echo-server/Julia/echo-server.julia
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using Sockets # for version 1.0
|
||||
println("Echo server on port 12321")
|
||||
try
|
||||
server = listen(12321)
|
||||
instance = 0
|
||||
while true
|
||||
sock = accept(server)
|
||||
instance += 1
|
||||
socklabel = "$(getsockname(sock)) number $instance"
|
||||
@async begin
|
||||
println("Server connected to socket $socklabel")
|
||||
write(sock, "Connected to echo server.\r\n")
|
||||
while isopen(sock)
|
||||
str = readline(sock)
|
||||
write(sock,"$str\r\n")
|
||||
println("Echoed $str to socket $socklabel")
|
||||
end
|
||||
println("Closed socket $socklabel")
|
||||
end
|
||||
end
|
||||
catch y
|
||||
println("Caught exception: $y")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue