Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a second try

Status
Not open for further replies.

jaschulz

Programmer
May 20, 2005
89
FR
I asked a question the other day about using javascript to do TCP, but nobody responded. What I want to do is simple enough: I just want to use javascript to send a request to the server at dict.org. Is that possible?

Thanks,

JAS
 
With ajax, yes.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
OK, but I thought ajax did not permit cross-domain stuff. Do you know of an example of this sort of thing that I could start from?

Thanks.

JAS
 
Do you know of an example of this sort of thing that I could start from?

Yes.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
OK, I'll play. Where can I find this example.
 

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Last try: I have googled all sorts of possibilities

ajax tcp

javascript tcp

javascript socket

etc.

and I found no example of anything like what I was looking for.

Plainly, I have annoyed you with my simple question, and I apologize for that, but I do need some real help.

Thanks,

JAS
 
You have googled all sorts of possibilities, but have you tried any of them to see if they work? Did you try modifying some of the code to see if you could get it to do what you want? You said that ajax won't work across domains but you weren't sure - did you try to see if it's a possibility?

This isn't a helpdesk to answer all your questions. You'll retain an answer to any of the questions you've posted above if you try it yourself first and see the results.

If you make an effort to solve this yourself and get stuck on the code, come back and paste it in this thread. Someone will examine your code and give you a suggestion based on the work you've done. That is what this forum is for, not to spoon feed you an answer to any question you might have. That is what google is for.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
If you make an effort to solve this yourself and get stuck on the code, come back and paste it in this thread.




You know... I think I have posted this comment probably no less than 50 times in this forum, and off the top of my head I can't remember one instance where someone actually did it. That means 100% of the time they just assume their not going to get someone to do the work for them and they just give up.


Please jaschulz, make a liar out of me.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
OK

According to RGC 2229, dict.org listens for TCP requests on port 2628 and should respond to the request "SHOW STRAT" by listing the available search strategies. So, I have tried:

var http_request = false;

function getContent() {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); }
} else if (window.ActiveXObject) { // IE
try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) {} }
}
if (!http_request) {
alert('ERROR: Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = showContent;
http_request.open('GET', ' SHOW STRAT');
http_request.send(null);
}

function showContent() {
if (http_request.readyState == 4) {
if (http_request.status == 200 || http_request.status == 0) {
alert(http_request.responseText);
}
} else {
alert('Error: Code(' + http_request.status + ')');
}
}


But all that gets me is the following error:


uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.open]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Documents%20and%20Settings/James%20A.%20Schulz/My%20Documents/CODE/WorkBench/test%20dict/testajax.js :: getContent :: line 18" data: no]
 
If you paste " SHOW STRAT" into your browser, what happens?

Initiating an ajax request is no different than typing the request string into your browser. If your browser won't return the data you're expecting, then you can't expect ajax to.



typing " SHOW STRAT" into my browser (firefox) redirected me to a google search page.

typing " just timed out

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
But then we're back to my first question: how do I make a TCP request with javascript.

A couple years ago, I wrote a dict client (in Delphi/Pascal) and it worked (and works) fine. I want to remake that application as a FireFox AddOn, but I am not making much progress so far.

You said at the beginning that I could do TCP via Ajax, but now you seem to be saying the opposite. I'm confused.

JAS
 
This frustration might be a terminology issue.

When you write that you want to make a "request" do you mean an HTTP Request?

Or do you just want to send some raw text packets to some port on some remote box and capture the reply as plain text?

Because the words REQUEST and RESPONSE have special meaning to web developers that is quite different than the plain English meaning.
 
I want to send raw text packets and capture the reply as plain text.

JAS
 
As far as I am aware you cant do TCP packet handling with javascript. The main reason being that it was designed to be an addon to html. I think you will have to go to a lower-level language in order to pull this off.


Now coding for a FF addon might be completely different. Its javascript....but its not. I haven't done much at all with addons so I cant even point you in the right direction.

For the record (to clear up any possible misunderstanding, and not assuming ignorance) Ajax is not an extension of javascript it is an application of it and a few other technologies. If javascript cannot do it ajax cannot do it.

Robert Carpenter
Remember....eternity is much longer than this ~80 years we will spend roaming this earth.
ô¿ô
 
kaht - While I realize an agree that good questions produce good answers and that people sometimes need to write better posts I don't think making somebody jump through hoops is at all necessary. Especially in a case like this where the apparent problem is sort-of in the "I don't even know where to start on this one" class.

Robert Carpenter
Remember....eternity is much longer than this ~80 years we will spend roaming this earth.
ô¿ô
 
For what it's worth, I found some stuff on yahoo(jslib.js, socket.js) that looks as if it might be what I need. If it works, I will report back.

Thanks to all.

JAS
 
kaht - While I realize an agree that good questions produce good answers and that people sometimes need to write better posts I don't think making somebody jump through hoops is at all necessary. Especially in a case like this where the apparent problem is sort-of in the "I don't even know where to start on this one" class.

Thank you for your opinion Robert - but in this case we will just have to agree to disagree.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
kaht - While I realize an agree that good questions produce good answers and that people sometimes need to write better posts I don't think making somebody jump through hoops is at all necessary. Especially in a case like this where the apparent problem is sort-of in the "I don't even know where to start on this one" class.
Here Here!

Glen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top