Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speed/Performance Characteristics of blocking vs Non-Blocking winsock

Is there in general a speed or performance difference in blocking and non-blocking Winsock TCP Sockets? I could get the differences of both sockets but there isn't a detailed performance comparison between the two types.

like image 909
Anantha Subramaniam Avatar asked Dec 19 '12 06:12

Anantha Subramaniam


1 Answers

Because it isn't about speed. The operations write and read are just memory copying in disguise. All they do is copy data to and from the kernel, respectively. I.e. they don't actually send or receive anything.

The blocking vs nonblocking feature asks: do you prefer these operations to block until completed or to return -1 and EAGAIN in case they can't be performed immediately ? For example, you read from a socket but there's nothing in the receive buffer. Do you prefer to have recv hanging until something comes along or to return -1 EAGAIN ?

like image 92
cnicutar Avatar answered Sep 21 '22 10:09

cnicutar