cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
9,824 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
12,207 Views
Registered: ‎08-21-2009

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
Highlighted
Contributor
Contributor
9,806 Views
Registered: ‎08-21-2009

#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
Highlighted
9,799 Views
Registered: ‎08-21-2008

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
Highlighted
Contributor
Contributor
9,797 Views
Registered: ‎08-21-2009

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
Highlighted
9,794 Views
Registered: ‎08-21-2008

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
Highlighted
Contributor
Contributor
9,791 Views
Registered: ‎08-21-2009

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
Highlighted
9,787 Views
Registered: ‎08-21-2008

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
Highlighted
Contributor
Contributor
9,771 Views
Registered: ‎08-21-2009

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
Highlighted
Contributor
Contributor
9,746 Views
Registered: ‎08-21-2009

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
12,208 Views
Registered: ‎08-21-2009

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
Highlighted
5,642 Views
Registered: ‎09-10-2009
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
Highlighted
Contributor
Contributor
5,625 Views
Registered: ‎08-21-2009

Hi!

Here are my suggestions:

 

-set lwip use in Software Platform Settings

-run LibGen

 

I hope its helpful.

 

Regards Chris

 

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

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
Highlighted
Visitor
Visitor
5,063 Views
Registered: ‎05-22-2010

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
Highlighted
Adventurer
Adventurer
4,393 Views
Registered: ‎01-18-2012

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