Hi there,
I am facing such a problem as I can't send anything by using TCP connection from Fibaro to my Raspberry Pi using a C language's Socket Server.
For more information, I am leaving my C's Socket Server as below. I can use telnet from my computer to send string to Raspberry Pi but I can't receive any string send from the Fibaro. I am using Raspberry's gpio to send Infrared code.
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main(int argc, char *argv[]){
int sockfd = 0,forClientSockfd = 0;
sockfd = socket(AF_INET, SOCK_STREAM,0);
int port = 8982;
if(sockfd == -1)
printf("Failed to Open Socket.\n");
struct sockaddr_in serverInfo, clientInfo;
int addrlen = sizeof(clientInfo);
bzero(&serverInfo, sizeof(serverInfo));
serverInfo.sin_family = PF_INET;
serverInfo.sin_addr.s_addr = INADDR_ANY;
serverInfo.sin_port = htons(port);
printf("Starting Server at Port %d", port);
bind(sockfd,(struct sockaddr *)&serverInfo,sizeof(serverInfo));
listen(sockfd,5);
char sock_message[] = {"Hello\n"};
forClientSockfd = accept(sockfd,(struct sockaddr*) &clientInfo, &addrlen);
send(forClientSockfd,sock_message,sizeof(sock_message),0);
char inputBuffer[256] = {};
while(1){
recv(forClientSockfd,inputBuffer,sizeof(inputBuffer),0);
printf("Get:%s\n",inputBuffer);
}
}
The Client Server's Code in Fibaro HC2 as below, and I am using a button to send String.
if not (started == 'YES') then
started = 'YES'
tcpSocket = Net.FTcpSocket("192.168.0.205",8982)
end
Thanks