sharing udp socket between several processes
Kirill Timofeev
kirill.timofeev at hulu.com
Tue Dec 29 21:20:43 CET 2015
Hi folks,
I'm trying to have single udp socket opened by the master process and
read data from it in the worker processes. Please find test source
attached. I'm using following simple ruby script to generate test traffic:
#!/usr/bin/env ruby
require 'socket'
u = UDPSocket.new
u.connect("127.0.0.1", 1234)
10000.times do |i|
u.send "this is line #{i}", 0
end
This works ok with single child:
$ ./a.out 1 1234 >log & ./gen-udp-traffic.rb && sleep 5 && killall a.out
&& grep -c udp_read_cb: log
[1] 22560
[1]+ Terminated ./a.out 1 1234 > log
10000
but I see that some incoming packets are lost with 2 childs:
$ ./a.out 2 1234 >log & ./gen-udp-traffic.rb && sleep 5 && killall a.out
&& grep -c udp_read_cb: log
[1] 23387
[1]+ Terminated ./a.out 2 1234 > log
8476
I run my tests on the ubuntu 14.04 x64. I use libev installed from the
package:
ii libev-dev 1:4.15-3 amd64 static
library, header files, and docs for libev
I compile my code using following command:
gcc 024-udp-test.c -lev
I tried to find any hints by googling, but unfortunately couldn't find
anything relevant.
Please advise what should I do to avoid packet loss.
Thanks,
Kirill.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 024-udp-test.c
Type: text/x-csrc
Size: 3303 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20151229/216407be/attachment.c>
More information about the libev
mailing list