Created
November 12, 2015 06:57
-
-
Save amitmurthy/4b01abb0ced926252b9c to your computer and use it in GitHub Desktop.
Echoing back 64 bytes on a socket connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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