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: 
Visitor harish89
Visitor
5,950 Views
Registered: ‎10-31-2012

Socket programming using ZedBoard

All,

 

I am trying to implement socket programs with sercer running on my ZedBoard and client running on my laptop. What hostname should I use when I try to create a socket connection?

 

Thanks

0 Kudos
5 Replies
Scholar milosoftware
Scholar
5,937 Views
Registered: ‎10-26-2012

Re: Socket programming using ZedBoard

Well, the hostname of the host you're connecting to would be what one would expect.

 

If you're new to sockets programming, I'd suggest starting with "localhost" and connect to yourself first. Once you have that running, proceed to more complicated matter.

 

If that wasn't helpful, it might help if you reveal what your zedboard is running and what's on your laptop and which language you're using and probably a dozen other things. For all we know now, you could be running windows CE on the zed, BSD on your laptop and you're programming it all in Cobol.

0 Kudos
Visitor harish89
Visitor
5,934 Views
Registered: ‎10-31-2012

Re: Socket programming using ZedBoard

I am new to socket programming. It works with the "localhost" and I am looking to communicate with zedboard and my laptop, both run Linux. Also, my programs are in C.

Any example code would help too

 

Thanks

0 Kudos
Visitor harish89
Visitor
5,669 Views
Registered: ‎10-31-2012

Re: Socket programming using ZedBoard

All,

 

I am still not able to communicate with sockets between the Zedboard and laptop.

 

It works when I run the Server on the Zed and Client on the laptop but DOES NOT work when I run the server on the laptop and client on the Zed. Both the server and client are in C and the laptop and Zed run Linux.

I am really baffled

Is someone else facing the same issue?

 

Below is  the code for server and client for reference. It simply takes stdin from client and transfers to stdout in server

 

//udp_server.c

#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>

int main(int argc, char**argv)
{
    int sockfd,n;
       struct sockaddr_in servaddr,cliaddr;
       socklen_t len;
       char mesg[1000];

       sockfd=socket(AF_INET,SOCK_DGRAM,0);

       bzero(&servaddr,sizeof(servaddr));
       servaddr.sin_family = AF_INET;
       servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
       servaddr.sin_port=htons(32000);
       bind(sockfd,(struct sockaddr *)&servaddr,sizeof(servaddr));

       for (;;)
       {
              len = sizeof(cliaddr);
              n = recvfrom(sockfd,mesg,1000,0,(struct sockaddr *)&cliaddr,&len);
              mesg[n] = 0;
              printf("Received the following:\n");
              printf("%s",mesg);
       }
}

 

//udp_client.c

#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>

int main(int argc, char**argv)
{
    int sockfd,n;
       struct sockaddr_in servaddr,cliaddr;
       char sendline[1000];

       if (argc != 2)
       {
              printf("usage:  udpcli <IP address>\n");
              exit(1);
       }

       sockfd=socket(AF_INET,SOCK_DGRAM,0);

       bzero(&servaddr,sizeof(servaddr));
       servaddr.sin_family = AF_INET;
       servaddr.sin_addr.s_addr=inet_addr(argv[1]);
       servaddr.sin_port=htons(32000);

       while (fgets(sendline, 10000,stdin) != NULL)
       {
              sendto(sockfd,sendline,strlen(sendline),0, (struct sockaddr *)&servaddr,sizeof(servaddr));
    }
}

0 Kudos
Scholar rfs613
Scholar
5,654 Views
Registered: ‎05-28-2013

Re: Socket programming using ZedBoard

It sounds like your laptop may have a firewall enabled. You'll want to disable this, or configure it to allow access to port 32000.
0 Kudos
1,480 Views
Registered: ‎03-19-2018

Re: Socket programming using ZedBoard

Hi!

I'm very new to xilinx vivado design and I'm trying to understand Zedboard. I could successfully run echo server on the Zedboard. Do I have to add these files(server.c & client.c) into same lwIP folder in order to establish communication between server and client? Because, when I created a new application, I got an error saying library files are missing.

Please  let me know how to go about...

Thanks in advance

0 Kudos