Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Send UDP Packet with ti.udp module to broadcast

$
0
0

I'll send an udp packet with ti.udp module: https://github.com/appcelerator/titanium_modules/tree/master/udp/mobile

But when i try to send a packet with this module, it gives an error in iOS Simulatur

[ERROR] :  Error Hit! Error Domain=NSPOSIXErrorDomain Code=13 "The operation couldn’t be completed. Permission denied"
and on device nothing happens (see in wireshark no packet).

Here my code:

exports.create = function() {
    var self = this,
    UDP = require('ti.udp'),
    socket = UDP.createSocket();
 
    socket.addEventListener('data', function (evt) {
        log(JSON.stringify(evt));
    });
 
    socket.addEventListener('error', function (evt) {
        log(JSON.stringify(evt));
    });
 
    self.mySend = function(macAddr) {
        var myData = [ 181, 10, 0, 0 ];
 
        socket.start({ port: 9 });
 
        setTimeout(function() {
 
            socket.sendString({
                host: '192.168.178.105',
                data: 'Hello, UDP!'
            });
 
            socket.sendBytes({ host:'192.168.178.105', data: myData });
 
        },2000);
 
        setTimeout(function() {
           socket.stop(); 
        },4000);
 
    };
 
    function log(text) {
        Ti.API.info('UDP Test: '+text);
    }
 
    return self;
};
Any Idea how to send UDP Packets with Titanium? Normaly i want to send bytes to broadcast, but all "step by step".

Thanks 4 help!


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>