Forum Discussion
Altera_Forum
Honored Contributor
16 years agoYes. The group of instructions ending with the memset() will free your rx buffer in order to accept more data, but the free space you get depends from how much rx data you can process.
I mean that maybe your problem is due to the fact the sss_exec_command() can't process data at the rate it arrives. Some questions which can help to identify the problem: Do the communication fail immediately or after a while? Do you have a bottleneck in your sss_exec_command() function? Do you send back anything after you have processed the command? Have you checked if your buffer gets full? (for example I used to set a pio output or LED if free_rx_space= SSS_RX_BUF_SIZE-(conn->rx_wr_pos-conn->rx_buffer) drops below a certain threshold) You may also replace code in your sss_handle_receive() with this simple echo test, in order to test if the overall connection is working. In this way you exclude possible problems in command processing and in buffer management. while(conn->state != CLOSE) { rx_code = recv(conn->fd, conn->rx_buffer, SOCKET_RX_BUF_SIZE, 0); if (rx_code <= 0) { conn->state = CLOSE; break; } bytes_to_process = rx_code; memcpy(tx_buf, conn->rx_buffer, bytes_to_process); if (send(conn->fd, tx_buf, bytes_to_process, 0) < 0) conn->state = CLOSE;; } Regards Cris