select - Socket data read wait time -
i have application listening on multiple sockets using select
. if start processing request came in socket , in meanwhile if request on socket b arrives want know how long socket b request had wait before it. since single threaded application cannot spawn new thread , go select
monitor again , instantly start processing request socket b.
is there 'c' api available me metric or not possible get?
there no straightforward way how measure interval between 'data ready' time , 'data read' time because there not timestamp written data. situation more complex because stream oriented socket may receive several data segments till select closed , not interval should measured.
if application data processing longer packet processing in kernel can reasonable measurement in following way:
- print current time , unique data id based on application protocol when select wakes due socket b data availability.
- log packet received socket b. can use either network traffic capture tool wireshark or tcpdump. or can configure iptables firewall rule (if running on linux) target
-j log
. - write simple script/program correlates captured packets , application log , subtract received , start processing time.
of course idea above ignore kernel processing time. if need exact time have introduce new thread application.
Comments
Post a Comment