Server:Two threads are created to process client requests. One thread is used to receive the connected Socket and add the Socket to a Queue object; another thread is used to propose the Socket in the Queue for receiving and sending operations. The receiving and sending operations are asynchronous.
Client:Create a NetworkStream instance (NetworkStream stream = new NetworkStream (Socket, true);) using a socket connected to the server, and package the NetworkStream instance into a System. IO. in the BufferedStream instance (/* used to receive */Stream inStream = new BufferedStream (stream);/* used to send */Stream outStream = new BufferedStream (stream );) send and receive data from the server.
Then I created a connection pool, initialized and created 10 server connections, and wrote a single-thread test program, extract the 10 connections from the connection pool to send and receive data in sequence. Everything is OK (the connection is returned to the connection pool ), but when I pull a connection from the connection pool again (10 created connections have been used up, this is the second connection, which has been used before) when sending and receiving data, the test program cannot receive the data returned by the server. (No matter on the client or server, I have not closed the connection after sending/receiving data)
From the log on the server side, the server receives the data sent from the client, and the server also successfully sends the data, but the client does not receive the data.
This problem has been plagued for the next two days ~