cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
6,210 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
Highlighted
Scholar
Scholar
6,197 Views
Registered: ‎10-26-2012

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
Highlighted
Visitor
Visitor
6,194 Views
Registered: ‎10-31-2012

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

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
Highlighted
Scholar
Scholar
5,914 Views
Registered: ‎05-28-2013

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
Highlighted
1,740 Views
Registered: ‎03-19-2018

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