I wrote a TCP IP client using stream socket and tried to communicate that with FPGA server. But the communication is not happening. At the same time from windows TCP/Ip client(written in C#)can communicate the FPGA board.
Please let me know if it is possible the Linux to FPGA communication using stream socket. I used AF_INET family to communicate the FPGA server.
}
int Close_Socket(LAN_MSG *TX)
{
if(close(TX->sock_fd) == -1)
{
// printf("\nCould not close socket\n");
return 0;
}
}
int Create_Socket()
{
struct hostent* pHostInfo; /* holds info about a machine */
struct sockaddr_in Address; /* Internet socket address stuct */
int socket_fd;
long nHostAddress;
char strHostName[200];
int nHostPort;
strcpy(strHostName,"localhost");
nHostPort=5000;
printf("\nMaking a socket");
/* make a socket */
socket_fd =socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if( socket_fd== -1)
{
printf("\nCould not make a socket\n");
return 0;
}
/* get IP address from name */
pHostInfo=gethostbyname(strHostName);
/* copy address into long */
memcpy(&nHostAddress,pHostInfo->h_addr,pHostInfo->h_length);
/* fill address struct */
Address.sin_addr.s_addr=nHostAddress;
Address.sin_port=htons(nHostPort);
Address.sin_family=AF_INET;
printf("\nConnecting to %s on port %d",strHostName,nHostPort);
/* connect to host */
if(connect(socket_fd,(struct sockaddr*)&Address,sizeof(Address)) == -1)
{
printf("\nCould not connect to host\n");
return 0;
}
return socket_fd;
}
This is my client communication layer. In this connect itself is failing. I am not understanding why connection itself is not establishing???