Skip to content

Instantly share code, notes, and snippets.

@amitmurthy
Created November 12, 2015 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitmurthy/4b01abb0ced926252b9c to your computer and use it in GitHub Desktop.
Save amitmurthy/4b01abb0ced926252b9c to your computer and use it in GitHub Desktop.
Echoing back 64 bytes on a socket connection
addprocs(1)
@everywhere begin
function server()
local s
local a
try
s = listen(9300)
while true
a = accept(s)
Base.disable_nagle(a)
println("got sock!")
@schedule begin
while true
x=deserialize(a)
serialize(a,x)
end
end
end
catch e
println(e)
finally
close(s)
close(a)
end
end
end
@spawnat 2 server()
const c = connect("localhost", 9300)
sleep(0.5)
function foo(n)
global c
Base.disable_nagle(c)
a=ones(8)
for i in 1:10^n
serialize(c, a)
deserialize(c)
end
end
foo(1)
@time foo(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment