Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-25-2003, 02:26 AM
Member
 
Join Date: Jun 2003
Posts: 39
Default Socket Broadcasting

When trying to broadcast using the following code I am not seeing any data been even been sent from my network card (snooping using Ethereal). Please help.

Code:
var s = new Socket;
s.create(1364, $SOCK_DGRAM);

var stream = new StringStream();

stream.write(0x09, 0x2b, .... 0x01);
s.sendTo(stream, stream.length, 64512);
Reply With Quote
  #2 (permalink)  
Old 09-25-2003, 03:12 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Socket Broadcasting

Hi, the socket must get the broadcast permission by using the setSockOpt method.

Code:
var s = new Socket;
s.create(1364, $SOCK_DGRAM);
s.setSockOpt(0x0020, 1);

var s2 = new Socket;
s2.create(64512, $SOCK_DGRAM);
s2.onReceive = function ()
{
var st = new StringStream;
this.receiveFrom(st, 65536);

trace(st);
}

var stream = new StringStream();

stream.write("hello");

s.sendTo(stream, stream.length, 64512);
Reply With Quote
  #3 (permalink)  
Old 09-25-2003, 05:08 AM
Member
 
Join Date: Jun 2003
Posts: 39
Default Re:Socket Broadcasting

Wow, thanks for the quick reply - what service!

That worked, now my next problem is when I send a byte using stream.write(0x09,0x2b...); it's showing 3 blank (00) bytes between each value sent.

How do I stop this?
Reply With Quote
  #4 (permalink)  
Old 09-25-2003, 01:51 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Socket Broadcasting

Hi,

The write methods takes the integer parameters as 4-bytes int, so you get three extra 00.

You can use the put method to avoid the problem.

Code:
stream.put(0x09);
...
stream.put(0x01);
Reply With Quote
  #5 (permalink)  
Old 12-20-2003, 03:52 AM
Member
 
Join Date: Jun 2003
Posts: 39
Default Re:Socket Broadcasting

I have implimented this and am getting a reply but for some reason I the SWFKit app not seeing all the data in the reply packet (only getting 42 bytes not 83 that I should be). Can you tell me why this would be occuring?
Reply With Quote
  #6 (permalink)  
Old 01-11-2004, 10:53 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Socket Broadcasting

Some data must have been lost. Please send us the code, we will help you to resolve the problem.
Reply With Quote
  #7 (permalink)  
Old 01-12-2004, 03:43 AM
Member
 
Join Date: Jun 2003
Posts: 39
Default Re:Socket Broadcasting

The code has been emailed to you.
Reply With Quote
  #8 (permalink)  
Old 01-12-2004, 12:16 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Socket Broadcasting

Hi, it works ok now. Please check mail.

Code:
var s2 = new Socket;
s2.create(64512, $SOCK_DGRAM);
s2.st = new StringStream;
s2.onReceive = function ()
{
   this.receiveFrom(this.st, 65535);
   
   if (this.st.length >= 126)
   {
   trace(this.st.length);
   for (i = 0; i < this.st.length; i++)
   {
   var value = this.st.get();
   var s = value.format("0x%02x");
   trace(s);
   }
   
   //reset the stringstream
   this.st.length = 0;
   this.st.getPos = this.st.putPos = 0;
   }
}
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:03 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.