lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] tcpip backlog issue and link status


From: Mrutyunjay
Subject: [lwip-users] tcpip backlog issue and link status
Date: Wed, 29 Sep 2010 17:29:41 +0530

hi ,
we are using Lwip in threaded environment (RTOS RT-Threads) on LM3S6911(Ti uC ).
According to change log files in BSP Lwip version is STABLE-1.3.2


Q1 . I have a issue in tcp listen api

issue is related to : Backlog parameter does not affect the listen queue

max client which can  be connected  with listening socket .
I need to restrict only one connection on listening socket ( uC as server ) 

Right now lwip allows up to 7 (client is PC )connection to the listening socket
but only the first connection can do the read and write operation the socket
remaining 6 connections are in queue .

I need to restrict the queue to Zero. i-e only one active connection.  

setting MAXCLIENT (tried with value 0 and 1 )in my code does not have any affect to tcp listen queue


#############################################################
from BSP source code
> \lwip\src\include\lwip\sockets.h
#define listen(a,b)           lwip_listen(a,b)




this is how i an using listen to tcp in my code
-----------------------------------------------------------------------------
# define MAXCLIENT 1 // only one client can connect
# define NETWORK_COMMAND_SERVER_PORT 8000 // we listen on tcp8000 port
# define HEADER_SIZE 12
-----------------------------------------------------------------------------
if ((server_socket = socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
         rt_kprintf("Socket error\n");
        return;
    }

    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(NETWORK_COMMAND_SERVER_PORT);
    server_addr.sin_addr.s_addr = INADDR_ANY;
    rt_memset(&(server_addr.sin_zero),8, sizeof(server_addr.sin_zero));

    if (bind(server_socket, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1)
    {
        rt_kprintf("Unable to bind\n");
        return;
    }

    if (listen(server_socket, MAXCLIENT) == -1)
    {
        rt_kprintf("Listen error\n");
        return;
    }

    sin_size = sizeof(struct sockaddr_in);
    connected = accept(server_socket, (struct sockaddr *)&client_addr, &sin_size);
    rt_kprintf("I got a connection from (%s , %d)\n",
    inet_ntoa(client_addr.sin_addr),ntohs(client_addr.sin_port));
while(1)
{
   // process received data : following call blocks till received or error
   bytes_received = read_bytes_from_socket(connected, (unsigned char *)&request_header.header, HEADER_SIZE);

    if(bytes_received <= 0)
    {
       rt_kprintf("\nSock Closed ");
    }

}
attached my lwip options files
------------------------------------------------------------------------------

Q2 .I need API interface to know status of Link to PHY

1. is Ethernet cable connected
2. and how is it connected
   a. 10bpms/100mbps
   b. full-duplex or half duplex


Regards,
Mrutyunjay B Patel

Attachment: rtconfig.h
Description: Binary data

Attachment: lwipopts.h
Description: Binary data


reply via email to

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