Hi All,

 

I am facing problem when I connect multiple clients to lwip server.

It works fine for single client.

When I connect multiple clients, after some time I get, tcp_write out of
memory error.

Clients having interframe delay 10ms.

 

Please suggest me a solution.

 

My opt.h settings are as below,

 

#define NO_SYS                                    1

#define TCP_TMR_INTERVAL          250 
#define TCP_SND_BUF                  5840 
#TCP_MSS                                 1460 
#define MEM_SIZE                       64000 
#define MEMP_NUM_TCP_PCB                             16 
#define MEMP_NUM_TCP_PCB_LISTEN       50 
#define MEMP_NUM_TCP_SEG                            50 
#define TCP_WND                                            (4 * TCP_MSS) 
#define TCP_SND_QUEUELEN                             ((4 * (TCP_SND_BUF) +
(TCP_MSS - 1))/(TCP_MSS))

 

Server code:

signed int prvxMBTCPPortReceive(void *arg, struct tcp_pcb *pxPCB, struct
pbuf *p, signed int Err)

{

 

            unsigned char *pModbusHeader;

            u16_t len;

            signed int Error;

            tcp_nagle_disable(pxPCB);

            if( Err != ERR_OK )

            {

                        return Err;

             }

    if( p == NULL )
// If pbuf is NULL then remote end has closed connection.

            {

                        prvvMBPortReleaseClient( pxPCB );

                        return ERR_OK;

             }

 

            len = p->tot_len;

            pModbusHeader = p->payload;

 

 

            MODTCP1 = ((struct mod_tcp_hdr1 *)pModbusHeader);

            Trans_id = MODTCP1->trans_id;

            Proto_ID = MODTCP1->proto_id;

            Len = MODTCP1->len;

            tcp_recved(pxPCB, p->len);

            tcp_tmr();

 

            memcpy( Comm3Buff, pModbusHeader + 6, (unsigned short)
*(pModbusHeader + 5) );

            ReceiveBuffLength3 = len - 6;

            ProcessSerialIntr3();

            //pcb->snd_queuelen =0x00;

            

                        

            MODTCP1 = ((struct mod_tcp_hdr1 *)&RxBuff[usTCPBufPos]);

            MODTCP1->trans_id = Trans_id;

            MODTCP1->proto_id = 0;

            MODTCP1->len =  htons((unsigned short)(FrameLength3-1));

 

            memcpy( &RxBuff[usTCPBufPos + 6], Comm3Buff, (unsigned short)
(FrameLength3 - 1) );

            if( (Error = tcp_write( pxPCB, RxBuff, (unsigned short)
(6+FrameLength3-1), 01 )) == ERR_OK )

{

                                    ( void )tcp_output( pxPCB );
//Make sure data gets sent immediately

                        }

                        else

                        {

                                                

                                    prvvMBPortReleaseClient( pxPCB );
// Drop the connection in case of an write error.

                        }

                        usTCPBufPos = 0;
// Reset the buffer.

                        

                        pbuf_free( p );

                        return ERR_OK;

}

 

Waiting for your reply,

 

 

 

Thanks & Regards,

Kranti Patil,

Embedded  Engineer,

REPL | PUNE | INDIA.

 

 

_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to