|
From: | saad saeed |
Subject: | [lwip-users] Socket API: Only six connections getting Accepted |
Date: | Sat, 26 Jan 2019 07:56:45 +0000 |
Hello,
I have a problem I am trying to establish multiple connections (9 in my case) with a server which is running on lwIP 2.0.2. My problem is I am trying to do this with Socket API. Following is my code
"
int s;
int n;
struct sockaddr_in addr;
struct sockaddr_in from;
char buff[80];
s=lwip_socket(AF_INET,SOCK_STREAM,0u);
if(s==-1)
{
PRINTF("Socket not created.\r\n");
}
else
{
PRINTF("Socket created.\r \n");
addr.sin_family=AF_INET;
addr.sin_port=htons(6500);
addr.sin_addr.s_addr=inet_addr("192.168.1.105");
if(lwip_bind(s,(struct sockaddr*)&addr,sizeof(addr)) < 0)
{
PRINTF("Binding error. \r\n");
}
else
{
fcntl(s, F_SETFL, O_NONBLOCK);
PRINTF("Binding recieve.\r \n");
if (lwip_listen(s,10) == -1)
{
PRINTF("Listen error. \r\n");
}
else
{
PRINTF("Listen successfull. \r\n");
socklen_t size =sizeof(from);
while(1)
{
n=lwip_accept(s,(struct sockaddr*) &from, &size);
if (n > 0)
{
PRINTF("Recieved a connection. \r\n");
}
}
}
}
}
"
But when I do this, I get less than 9 connections accepted, probably around 7 or 6. I have also tried doing this using NETCON API and my code is I got the desired
connections accepted.
"
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, IP_ADDR_ANY, 6500);
LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);
netconn_listen(conn);
while (1) {
err = netconn_accept(conn, &newconn);
if (err == ERR_OK) {
PRINTF("accepted new connection %p \r\n", newconn);
}
}
"
For convenience, I am attaching my lwip_opt.h and opt.h files. Please, help me with this.
Kind Regards,
Saad.
|
lwipopts.h
Description: lwipopts.h
opt.h
Description: opt.h
[Prev in Thread] | Current Thread | [Next in Thread] |