Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7987885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:16:35+00:00 2026-06-04T12:16:35+00:00

Since Javascript does not have any functionality by itself to communicate over raw sockets

  • 0

Since Javascript does not have any functionality by itself to communicate over raw sockets , I decided to use a Java applet – and on the event that the user has disabled java applets on his browser , a flash socket bridge to be integrated with Javascript. I have tried with both jsxmlsocket as well as haxejssocket only to face the same problem

Now , the server application is written in Java and communication works fine over the java applet. But on flash , there seems to be a problem.

The first text that flash recieves is the response to <policy-file-request/> allowing access to all domains and ports. This works fine , since the sockets start to communicate

Here is the Javascript code that runs when data is received:

socket.onData = function(data) {
    alert(data);
    parse(data);
}

Now , here’s the problem. After the response to <policy-file-request/> is sent , 5 more lines of text are sent. What is expected of course is that I will see 5 alert boxes with the text sent in it.
That doesn’t seem to be the case. What I see instead is 5 alert boxed with the response to <policy-file-request/> in it. It looks like something is being sent , cause the OnData function seems to firing off at the correct time , but for some reason , the data seems to be the first line of text sent to it.

Java thread that takes care of sending data:

LinkedBlockingQueue<String> outQueue=new LinkedBlockingQueue<String>(1000);
public Thread checkSendLoop=new Thread(){ //this is done to cramp everything in one file. Also more neater
    public void run(){
        try{
            OutputStream out=socket.getOutputStream();
            while (true){
                String mes=outQueue.take();
                mes=mes.replace("\n", "").replace("\r", ""); //for safety
                mes=mes+"\0"; //append
                out.write(mes.getBytes());
                out.flush();
            }
        }
        catch (Exception e){
            System.out.println("FATAL : Data to a client will not be sent anymore."); //probably a socket close threw the exception
            outQueue.clear();
            outQueue=null;
        }
    }
};

To send data , a send function is called:

public void send(String s){
    Queue<String> testQueue = outQueue;
    s=s+" "+getUnixTime();
    if (testQueue!=null){
        System.out.println("SENDING "+nick+" - "+s);
        testQueue.add(s); //just add to the queue , the check loop will make sure that its sent
    }
}

As you can see , all data sent ends with a null byte or \0. Maybe this is responsible?

NOTE: I want to emphasize here that I am familiar with websockets and how they would be “much more appropriate” , so please do not suggest that.

As mentioned earlier , it works fine in other clients like Telnet and the Java applet.

Update: No, this is not a duplicate of this question. My problem has to do with the script returning only the response to <policy-file-request/> on every onData call. There is no “error” thrown in the process.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:16:36+00:00Added an answer on June 4, 2026 at 12:16 pm

    From what I can see , this looks like some sort of internal compatibility issue. Your code seems fine , so that means that there must be some sort of incompatibility between the code and the version of the software that’s running it , thus causing a problem.

    Its a pretty far fetched guess but it looks like the only thing here that could actually cause that error

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since JavaScript is not derived from Java, why does it have Java in the
Technically this might not be classed as a programming question, since I have already
using Facebook Javascript SDK (since FBml doesn't work anymore), posting to a wall using
Since I installed IE8 (Win XP) Visual Studio 2008 Pro stopped deebugging javascript. When
Javascript's getTime() method returns the number of milliseconds since midnight of January 1, 1970.
Using JavaScript SDK, it is possible to wall post with user's consent. Since It
Since version 1.5 Subversion supports to have a local caching-proxy for the main Master-repository.
Since Eclipse 3.5 there seems to be no option to have drop a plugin
I have made the following javascript to be used in my jQuery based website.
In what seems to be random occurrences, javascript files are not loading . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.