1

Topic: Flow on a socket or epoll

https://stackoverflow.com/q/47440302/1746434 Application-client accepts the data from two ports of one server. Speed of a flow small, nearby 2Kb/with that is strong less throughput of network connection of the client. The processor on the client modern ARMv7 or x86-64. That it is better concerning saving of resources of the client: 1. To launch one flow and to wait through epoll. At data accessability to read in not locked a mode both sockets by turns (if both are accessible). 2. To launch on a flow on a socket and to read in a locked mode. How to calculate in the second variant possibility of loss of the data. How generally to calculate possibility of loss of packet UDP if the data gets from the buffer too late? Whether the rights I, what if the person are not present a difference, launching one flow, OS resources as there is no superfluous switching of a context are saved?

2

Re: Flow on a socket or epoll

Hello, mbait, you wrote: M> Speed of a flow small, nearby 2Kb/with that is strong more throughput of network connection of the client. Here this phrase any not clear. I would use epoll.

3

Re: Flow on a socket or epoll

Hello, mbait, you wrote: M> M> 1. To launch one flow and to wait through epoll. At data accessability to read in not locked a mode both sockets by turns (if both are accessible). M> 2. To launch on a flow on a socket and to read in a locked mode. M> if at you one socket, it is better to use poll () or select (). epoll - a good piece, but its advantages are uncovered, if it is a lot of sockets. M> How to calculate in the second variant possibility of loss of the data. How generally to calculate possibility of loss of packet UDP if the data gets from the buffer too late? Whether the rights I, what if the person are not present a difference, launching one flow, OS resources as there is no superfluous switching of a context are saved? Also brain resources of the programmer are saved. In the multi-threaded program there are many interesting and rather nontrivial questions which in the one-continuous program simply do not arise. How you, for example, are going to stop this flow which hangs in locked reading from a socket?

4

Re: Flow on a socket or epoll

Hello, Glory, you wrote: Here this phrase any not clear. Corrigendas, it is necessary to read as "strongly less".

5

Re: Flow on a socket or epoll

Hello, Pzz, you wrote: Pzz> Also brain resources of the programmer are saved. In the multi-threaded program there are many interesting and rather nontrivial questions which in the one-continuous program simply do not arise. Pzz> as you, for example, are going to stop this flow which hangs in locked reading from a socket? Good thought, did not think of it.

6

Re: Flow on a socket or epoll

Hello, mbait, you wrote: Pzz>> As you, for example, are going to stop this flow which hangs in locked reading from a socket? M> good thought, did not think of it. Well and it is correct. To think harmfully.

7

Re: Flow on a socket or epoll

Hello, Pzz, you wrote: Pzz> Hello, mbait, you wrote: Pzz>>> As you, for example, are going to stop this flow which hangs in locked reading from a socket? M>> good thought, did not think of it. Pzz> well and it is correct. To think harmfully. And here now thought, and decided that shutdown (2) forces locking calls to return-1.

8

Re: Flow on a socket or epoll

Hello, mbait, you wrote: M> M> 1. To launch one flow and to wait through epoll. At data accessability to read in not locked a mode both sockets by turns (if both are accessible). M> the first is better, but it is more difficult for making. It is possible to take ready  like boost:: asio or libevent. It is possible to use instead of epoll - select. M> How to calculate in the second variant possibility of loss of the data. How generally to calculate possibility of loss of packet UDP if the data gets from the buffer too late? Whether the rights I, what if the person are not present a difference, launching one flow, OS resources as there is no superfluous switching of a context are saved? You have not enough flows, it is possible to neglect context switching.

9

Re: Flow on a socket or epoll

Hello, Kernan, you wrote: K> the first is better, but it is more difficult for making. It is possible to take ready  like boost:: asio or libevent. It is possible to use instead of epoll - select. There are any latent difficulties? Never worked with epoll before, worked with libevent, but the example from "Example of suggested usages" epoll does not cause (2) questions.

10

Re: Flow on a socket or epoll

Hello, mbait, you wrote: M> Hello, Kernan, you wrote: K>> the first is better, but it is more difficult for making. It is possible to take ready  like boost:: asio or libevent. It is possible to use instead of epoll - select. M> There are any latent difficulties? Never worked with epoll before, worked with libevent, but the example from "Example of suggested usages" epoll does not cause (2) questions. There not that it is a lot of complexity, it is simple hardly more code and the logic of application is a bit more difficult. If problems does not cause, write safely.

11

Re: Flow on a socket or epoll

Pzz> As you, for example, are going to stop this flow which hangs in locked reading from a socket? To take yes to close a socket, yes though from UI-treda.

12

Re: Flow on a socket or epoll

Hello, SkyDance, you wrote: Pzz>> As you, for example, are going to stop this flow which hangs in locked reading from a socket? SD> to take yes to close a socket, yes though from UI-treda. And now we imagine that we close a socket from any one flow, and any other flow still something opens in the meantime. In  it something receives the first free file descriptor. I.e. what was just released from under a socket. Well and in  - as carries. And the flow which works with a socket, it about it knows nothing. Therefore it also continues to work to itself(himself), indifferently. With absolutely outside for it a file descriptor. Here it with it turns out, to universal amazement.

13

Re: Flow on a socket or epoll

Pzz> And now we imagine that we close a socket from any one flow, and any other flow still something opens in the meantime. In  it something receives the first free file descriptor. I.e. what was just released from under a socket. Well and in  - as carries. And the flow which works with a socket, it about it knows nothing. Therefore it also continues to work to itself(himself), indifferently. With absolutely outside for it a file descriptor. Here it with it turns out, to universal amazement. Write the program which plays back this behavior, and be surprised.

14

Re: Flow on a socket or epoll

Hello, Pzz, you wrote: Pzz> And now we imagine that we close a socket from any one flow, and any other flow still something opens in the meantime. In  it something receives the first free file descriptor. I.e. what was just released from under a socket. Well and in  - as carries. And the flow which works with a socket, it about it knows nothing. Therefore it also continues to work to itself(himself), indifferently. With absolutely outside for it a file descriptor. Here it with it turns out, to universal amazement.

15

Re: Flow on a socket or epoll

Hello, mbait, you wrote: M> M> 1. To launch one flow and to wait through epoll. At data accessability to read in not locked a mode both sockets by turns (if both are accessible). M> 2. To launch on a flow on a socket and to read in a locked mode. M> the second. It is not necessary to produce complexities out of the blue. Whether M> the rights I, what if differences the person are not present, launching one flow, OS resources as there is no superfluous switching of a context are saved? Saving on matches, to be exact even so, you try to solve which problem are not present (performance at the traffic in 2kb/c).