UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
9,483 Views
Registered: ‎08-21-2009

lwip_accept() problems

Jump to solution

Hi all!

I implemented a client on my spartan 3A DSP 1800A Board with MicroBlaze/xilkernel/socket API

and it runs fine with a PC-Server

Now I'm trying to set up a server on my board but it doesn't run.

The program is executed until function lwip_accept() is called.

If I connect a client from my PC to the server the server

closes the connection .

I read the other post where they recommended to set up the

linkspeed for temac, but I use emac-IP...

I would be very pleased if anyone could help me!

 

Regards  Chris

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Contributor
Contributor
11,866 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

I solved the problem with a long time troubleshoot....

The problem was that I missed to set a higher number

of semaphores in my Software Platform Settings.

 

My new settings:

config_sema: true

max_sem: 50

max_sem_waitq: 20

 

Thanks for help!

 

Regards Chris

View solution in original post

0 Kudos
14 Replies
Contributor
Contributor
9,465 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

#include <stdio.h> #include <string.h> #include "lwip/inet.h" #include "lwip/sockets.h" #include "lwip/sys.h" #include "lwipopts.h" #include "netif/xadapter.h" u16_t bindport2 = 2002; void recv_send_subroutine(void *p); void server_accept_thread() { char *host={"192.168.1.50"}; int sock, err, NewSock, len; struct sockaddr_in client_addr, server_addr; struct in_addr sIPaddr; if ((sock = lwip_socket(AF_INET, SOCK_STREAM, 0)) < 0) { return; } server_addr.sin_family = AF_INET; server_addr.sin_port = htons(bindport2); server_addr.sin_addr.s_addr = INADDR_ANY; if (lwip_bind(sock, (struct sockaddr *)&server_addr, sizeof (server_addr)) < 0) { return; } lwip_listen(sock,5); len = sizeof(client_addr); while (1) { NewSock = lwip_accept(sock, (struct sockaddr *)&client_addr, &len); recv_send_subroutine((void *)NewSock); lwip_close(sock); } } //------------------------------------------------ void recv_send_subroutine(void *p) { int sock = (int)p; int SEND_BUF_SIZE = 256; char send_buf[SEND_BUF_SIZE]; int i,j,MsgLen; for(j=0;j<4;j++) { for(i=0;i<=256;i++) { send_buf[i]='0'; } MsgLen = lwip_recv(sock, send_buf, SEND_BUF_SIZE, 0); lwip_send(sock, send_buf, MsgLen, 0); if(send_buf[0] == 'q') { break; } } }

 

Hi all!!

I added my c-file where I start the server and receive client-messages and return a message to the client. The Network Interface setup is the same I

used before when running a client on the board...

Maybe someone of you could check the code and give a comment on it.

Thanks

Regards chris

Message Edited by c.schmidt on 09-23-2009 10:51 PM
0 Kudos
9,458 Views
Registered: ‎08-21-2008

Re: lwip_accept() problems

Jump to solution

Hello.

I would suggest having a look at xapp1026.

See for the file echo.c

You may get your answer there. 

Best of luck.
--
Unlimited in my Limits.
0 Kudos
Contributor
Contributor
9,456 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

Thanks for replying !

My code is based on the echo server application xapp1026.

I use the same functions in the same order with the same

kind of arguments. I first implemented a client because

the echo-server doesn't work...

What do you think, could there be a hardware failure,

or is there  a problem with my software-application?

 

Regards Chris

0 Kudos
9,453 Views
Registered: ‎08-21-2008

Re: lwip_accept() problems

Jump to solution

Hello.

What may be happening is that after accepting the connection from PC client it moves on to

recv_send_subroutine()

 And in the subroutine the functions lwip_send() and lwip_recv() used may be non blocking functions(i may be wrong) so what may be happening is that the whole subroutine may be getting executed irrespective of whether the data has arrived at the socket or not.

The moment the whole subroutine function is executed the pointer returns to the location from where the function was called and then it executes the next instructions which says

 

lwip_close(sock);

and hence the socket (connection) closes.

 

Try to put some polling statements in between like say in lwip_recv().

 

Best of luck.
--
Unlimited in my Limits.
0 Kudos
Contributor
Contributor
9,450 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

I added a test statement after the lwip_accept() function. But it is never reached.

I think that lwip_accept does connect to the client but does not return ...

Any Idea why it does not return?

Thanks for help!!

Regards

0 Kudos
9,446 Views
Registered: ‎08-21-2008

Re: lwip_accept() problems

Jump to solution

Hello. 

Connect the serial port as well and see if it is displaying something on hyperterminal after the lwip_accept() function is executed.

Best of luck.
--
Unlimited in my Limits.
0 Kudos
Contributor
Contributor
9,430 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) { struct lwip_socket *sock; struct netconn *newconn; struct ip_addr naddr; u16_t port; int newsock; struct sockaddr_in sin; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } newconn = netconn_accept(sock->conn); /* get the IP address and port of the remote host */ netconn_peer(newconn, &naddr, &port); memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = naddr.addr; if (*addrlen > sizeof(sin)) *addrlen = sizeof(sin); memcpy(addr, &sin, *addrlen); newsock = alloc_socket(newconn); if (newsock ==

Hi!

I added a serial output after the lwip_accept() function-call. But nothing was printed out.

I checked the lwip_accept function. Inside this function is a call that never returns: netconn_accept

 

0 Kudos
Contributor
Contributor
9,405 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

Hi all!

 

Here some more facts:

Client and server do connect, I checked it by using wireshark...

After this the client sends one Frame with the data I expected.

But then the server on my board sends a RST , ACK Frame

which means that the server stops the connection.

Waiting for your answer!

Thanks

Regards Chris

 

0 Kudos
Highlighted
Contributor
Contributor
11,867 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

I solved the problem with a long time troubleshoot....

The problem was that I missed to set a higher number

of semaphores in my Software Platform Settings.

 

My new settings:

config_sema: true

max_sem: 50

max_sem_waitq: 20

 

Thanks for help!

 

Regards Chris

View solution in original post

0 Kudos
5,301 Views
Registered: ‎09-10-2009

Re: lwip_accept() problems

Jump to solution
Hi all... i got stuck with web server application.My board info. ml507 with powerpc440. I tried to implement application with xapp1026 as my reference. But when i tried to program the file from sdk it is showing 2 errors. Error :dispatch.c:19:22: error: lwip/inet.h: No such file or directory ../dispatch.c:20:25: error: lwip/ip_addr.h: No such file or directory do i need to specify any kinda path to include these headers?? Thanks, KS R
0 Kudos
Contributor
Contributor
5,284 Views
Registered: ‎08-21-2009

Re: lwip_accept() problems

Jump to solution

Hi!

Here are my suggestions:

 

-set lwip use in Software Platform Settings

-run LibGen

 

I hope its helpful.

 

Regards Chris

 

0 Kudos
5,269 Views
Registered: ‎09-10-2009

Re: lwip_accept() problems

Jump to solution

Hi Chris,

I checked for lwip in s/w platform settings --> use.

Well, i solved it by just changing path of workspace n lil change in code.

Thanks

KS R  

0 Kudos
Visitor naz56
Visitor
4,722 Views
Registered: ‎05-22-2010

Re: lwip_accept() problems

Jump to solution

hello

 

do we need to use enable timers interrupts  functions explicilty ???can u plz show ur "network thread" function here??

 

thanx in advance

 

 

0 Kudos
Adventurer
Adventurer
4,052 Views
Registered: ‎01-18-2012

Re: lwip_accept() problems

Jump to solution

My new settings:

config_sema: true

max_sem: 50

max_sem_waitq: 20



Thank you so much!!!

Even if this post is over 3 year old, it solve the problem i was working on for 3 week now...

Thank you again!!

0 Kudos