Frage

I have a TCP server using select to get data from a client through TCP socket. The Server is slow in consuming data while the client is much faster. My client sends 8 bytes of data and each time it -open a new connection -write data -disconnect Because of this ( the server socket must accept many connection ) I increased the backlock value of listen to 500.

Despite this setting, at some point I can see that -my client blocks in a pthread function called __connect_nocancel and this happens many times. -after a while my server starts receiving data out of orders. The first data messed up is the one where the client blocks ( followed by other ).

I thought that increasing the backlog may fix this but this issue but this is not the case.

Can You help me? I am in Linux 2.6.32

Cheers

AFG

War es hilfreich?

Lösung

The backlog parameter of listen(2) is usually capped to some value inside the OS network stack. On Linux the default is 128.

The real problem though is, as @EJP is saying, you are totally mis-using TCP.

Andere Tipps

If ordering is important, your client must just keep a single connection open and write everything via that single connection. There are no two ways about this. TCP guarantees byte ordering withing the stream. Nothing guarantees the ordering of server-side processing of distinct connections.

It's also considerably more efficient. At present you are exchanging about eight packets for every eight bytes, which implies an overhead of up to 160 bytes.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top