Languages

Menu
Sites
Language
UDP Tizen 3.0 wearable sendto() returns errno 13 permission denied

 

 I have the persmissions correct I beleive.

privilege/download

privilege/push

privilege/network.set

privilege/network.ge

feature/network.internet

feature/network.wifi

 

    		                int sock2;
				memset((char *)&sock2, 0, sizeof(sock2));
				sock2 = socket(AF_INET, SOCK_DGRAM, 0);
				if (sock2 < 0) {
					display("Network err: Cannot make socket\n");
					return;
				}
			
				
				int on=1;
				int success = setsockopt(sock2, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
				if (success < 0) {
					display("setsockopt failed\n");
					return;
				}
				
				//reply
				const char* reply = "watch";
				
				sockaddr_in data_to;
				data_to.sin_family = AF_INET;
				data_to.sin_port = htons((u_short)ATTENDANCE_PORT);//attendance port is 22142
				data_to.sin_addr.s_addr = inet_addr("127.0.0.0");
				
				int ret = sendto(sock2, reply, 5 , 0, (struct sockaddr *)&data_to, sizeof(sockaddr_in));
				
				if (ret == -1){	
					sprintf(err, "Network Err %i", errno);
					display(const_cast<const char*>(err));
				}
				
				return;

Responses

4 Replies
Shaswati Saha

Would you please try with the below line 

data_to.sin_port = htons(0);

instead of 

data_to.sin_port = htons((u_short)ATTENDANCE_PORT);

I guess, it may work as this link says that it asks the operating system to pick any available port number by setting the port to 0.

Chip Weinberger

Gave it a shot. Same error.

Also I just ran the same code on Android and it worked. So this seems to be Tizen specific.

Chip Weinberger
    			int sock2;
				memset((char *)&sock2, 0, sizeof(sock2));
				sock2 = socket(AF_INET, SOCK_STREAM, 0);
				if (sock2 < 0) {
					display("Network err: Cannot make socket\n");
					return;
				}
			
								
				display("Connected");
				
				sockaddr_in watch_server;
				watch_server.sin_addr.s_addr = data_from.sin_addr.s_addr;
				watch_server.sin_family = AF_INET;
    			watch_server.sin_port = htons( WATCH_ATTENDANCE_PORT );
    			
    			server_address = watch_server;
    			server_addr_isValid = true;
				
				//Connect to remote server
    			if (connect(sock2 , (struct sockaddr *)&watch_server , sizeof(watch_server)) < 0)
    			{
					sprintf(err, "Network Err %i", errno);
					display(const_cast<const char*>(err));
    			}

Okay, I've also tried TCP and I'm getting the same error 13 when i try to connect.

Note, I am able to recieve data over UDP, but I cannot send data over UDP or connect to a remote server over TCP.

This must be a permissions issue. 

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.example.connecttoviveserver" version="1.0.0">
    <author email="chip.weinberger@otoy.com" href="otoy.com">Otoy</author>
    <description>Relay interaction events to vive server</description>
    <profile name="wearable"/>
    <ui-application appid="org.example.connecttoviveserver" exec="connecttoviveserver" multiple="false" nodisplay="false" taskmanage="true" type="capp">
        <label>Connect To Vive Server</label>
        <icon>otoy.png</icon>
    </ui-application>
    <privileges>
        <privilege>http://tizen.org/privilege/download</privilege>
        <privilege>http://tizen.org/privilege/push</privilege>
        <privilege>http://tizen.org/privilege/network.set</privilege>
         <privilege>http://tizen.org/privilege/network.get</privilege>
    </privileges>
    <feature name="http://tizen.org/feature/network.internet">true</feature>
    <feature name="http://tizen.org/feature/network.wifi">true</feature>
</manifest>



 

Chip Weinberger

I figured it out. I was missing the internet priveledge.....