09-23-2009 07:06 AM
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
09-27-2009 10:39 PM
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
09-23-2009 10:49 PM - edited 09-23-2009 10:51 PM
#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
09-24-2009 12:06 AM
Hello.
I would suggest having a look at xapp1026.
See for the file echo.c
You may get your answer there.
09-24-2009 12:14 AM
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
09-24-2009 12:28 AM
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().
09-24-2009 12:42 AM
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
09-24-2009 12:54 AM
Hello.
Connect the serial port as well and see if it is displaying something on hyperterminal after the lwip_accept() function is executed.
09-24-2009 04:07 AM
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
09-25-2009 03:57 AM
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
09-27-2009 10:39 PM
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
09-29-2009 08:40 AM
09-29-2009 10:52 PM
Hi!
Here are my suggestions:
-set lwip use in Software Platform Settings
-run LibGen
I hope its helpful.
Regards Chris
10-01-2009 08:28 AM
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
05-31-2010 02:57 AM
hello
do we need to use enable timers interrupts functions explicilty ???can u plz show ur "network thread" function here??
thanx in advance
04-24-2013 01:14 AM
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!!