lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Query on simultaneous Client and Server using lwip


From: Sanchayan
Subject: [lwip-users] Query on simultaneous Client and Server using lwip
Date: Thu, 02 Aug 2012 11:24:17 +0530
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

Hello everyone,

I am using lwip 1.3.2 on Stellaris LM3S6965 ARM Cortex M3 processor and trying to get both server and client working simultaneously.

1. For my application, i am running a server, by initiating a listening connection on Port 2101. On getting a connection request, i serve data as per request. Below is the initialization part.

    // Create a new TCP Protocol Control Buffer abbreviated as PCB.   
      pcb = tcp_new();

    // Bind the PCB to a Port and any IP address.
      tcp_bind( pcb, IP_ADDR_ANY, 2101 );   
   
    // Put the PCB and TCP connection on Board in listening state       
    pcb = tcp_listen( pcb );

    // This function specifies the callback function that will be called when a client asks for connection with board
    tcp_accept( pcb, connection_accept );

2. Another client is running on Port 2103 trying to connect to a server application running on PC for sending data. If connection is established, it sends the data at 5 seconds interval and keeps retrying every 5 seconds if connection fails or is not established.

     err_t conn_err, bind_err ;     

    struct ip_addr ip_addr_server = { 0x4701110A };   
  
    log_pcb = tcp_new();

    bind_err = tcp_bind( log_pcb, IP_ADDR_ANY, 2103 );   
       
    if( bind_err != ERR_OK )
    {
        return bind_err;   
    }
    else if( bind_err == ERR_OK )
        {
            conn_err = tcp_connect(log_pcb, &ip_addr_server, 2103, callback_connected);       
       
        }
  
    return conn_err;   


For the second point, the above is in a function and gets called in the main(),  while(1)  loop of the program. On calling tcp_connect(), i get a ERR_USE -11 Address in Use error. But, my data does get sent, though the data sending is not reliable. A few blocks of data is send, but, no data is sent after sending the first few blocks. I checked in Wireshark, no RST is send and the connection is not closed. Is what i am doing correct and can be accomplished?

On a different note, i also call tcp_write(), in the main loop of the program outside the interrupt context of lwip, for sending data on both connections.  Is this way of using tcp_write correct?.

Any suggestions or help will be most appreciated. Thanks in advance.

Thanks & Regards,
Sanchayan Maity.
Asst Manager | Godrej & Boyce Mfg. Co. Ltd.
Godrej Security Solutions | PSS Tech Cell
Vikhroli, Mumbai - 400709.
Maharashtra, India.



Disclaimer: This message (including any attachments) contains confidential information and is intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited. If you have received this email in error please notify address@hidden Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Godrej & Boyce Mfg. Co. Ltd. group of companies. The recipient should check this email and any attachments for the presence of viruses. Godrej & Boyce Mfg. Co. Ltd. group of companies accepts no liability for any damage caused by any virus transmitted by this email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]