Hi,
I'm building a simple application to stream some sensor data directly to the computer from the Gear 3 watch. I've connected both devices to the same wifi network. So I've implemented a server socket in the laptop and client in the watch. But the problem I'm having is, the connection cannot be established.
I used the privilege: tizen.org/privilege/internet
But I'm not sure this is the correct one to use. And my socket client code is this (fairly simple C++ socket client code)
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'; min-height: 14.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'; color: #4e9072} span.s1 {color: #931a68} span.s2 {color: #793d93} span.s3 {color: #0326cc} span.s4 {color: #3933ff} span.s5 {color: #000000} span.s6 {color: #006141} span.Apple-tab-span {white-space:pre}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'; color: #006141} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'; color: #3933ff} span.s1 {color: #931a68} span.s2 {color: #000000} span.s3 {color: #006141}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'; color: #3933ff} span.s1 {color: #931a68} span.s2 {color: #000000}
#include <stdio.h> #include <sys/socket.h> #include <stdlib.h> #include <netinet/in.h> #include <arpa/inet.h> struct sockaddr_in address; int sock = 0, valread; struct sockaddr_in serv_addr; char *hello = "Hello from client"; char buffer[1024] = {0}; if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { elm_object_text_set(ad->txt_ppg, "Socket creation error"); return -1; } memset(&serv_addr, '0', sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(PORT); // Convert IPv4 and IPv6 addresses from text to binary form if(inet_pton(AF_INET, "192.168.43.184", &serv_addr.sin_addr)<=0) { elm_object_text_set(ad->txt_ppg, "Invalid address"); return -1; } if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { belm_object_text_set(ad->txt_ppg, "Connection Failed"); return -1; } send(sock , hello , strlen(hello) , 0 );
But the problem is, with
connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr))
method, I'm always getting -1.
Can anyone suggest me a solution for this. Or, is there any method I can directly send data to the laptop?
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Eco Sans Mono'}