By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

Socket in a web page - possible?

P: n/a
I would like to serve out a web page (intranet only - no internet)
that has the ability to open a client-side socket that connects to a
server-side socket on another computer. This connection is used to
send data to be displayed using DHTML on the web page (as opposed to
refreshing the entire page).

I have this working where the client is running Internet Explorer in
Windows (the client-side socket is an ActiveX DLL). I would like to
get this to work from a Mozilla browser running in Linux. The ActiveX
stuff, of course, will not work there.

Is there something I can use in a Javascript that will work in Linux?

TIA
Jul 20 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a


Martin wrote:
I would like to serve out a web page (intranet only - no internet)
that has the ability to open a client-side socket that connects to a
server-side socket on another computer. This connection is used to
send data to be displayed using DHTML on the web page (as opposed to
refreshing the entire page).

I have this working where the client is running Internet Explorer in
Windows (the client-side socket is an ActiveX DLL). I would like to
get this to work from a Mozilla browser running in Linux. The ActiveX
stuff, of course, will not work there.

Is there something I can use in a Javascript that will work in Linux?


Mozilla has XMLHttpRequest since Netscape 6/pre Mozilla 1.0 times, it
has a SOAP API since Mozilla 1.0 and it has a high-level web service API
since Mozilla 1.4, see
http://www.mozilla.org/projects/webservices/
All ways to send data to a HTTP server and receive data back with script
without any need to refresh an HTML window/frame document
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
On Wed, 11 Feb 2004 10:17:31 -0700, Martin <ma**********@comcast.net>
wrote:
I would like to serve out a web page (intranet only - no internet)
that has the ability to open a client-side socket that connects to a
server-side socket on another computer. This connection is used to
send data to be displayed using DHTML on the web page (as opposed to
refreshing the entire page).

I have this working where the client is running Internet Explorer in
Windows (the client-side socket is an ActiveX DLL). I would like to
get this to work from a Mozilla browser running in Linux. The ActiveX
stuff, of course, will not work there.

Is there something I can use in a Javascript that will work in Linux?


No, but you can use a Java applet, as long as the server that it connects
to is the same machine that serves the applet (a security measure).

Ask in comp.lang.java for more information.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3

P: n/a
Martin wrote:
I would like to serve out a web page (intranet only - no internet)
that has the ability to open a client-side socket that connects to a
server-side socket on another computer. This connection is used to
send data to be displayed using DHTML on the web page (as opposed to
refreshing the entire page).

I have this working where the client is running Internet Explorer in
Windows (the client-side socket is an ActiveX DLL). I would like to
get this to work from a Mozilla browser running in Linux. The ActiveX
stuff, of course, will not work there.

Is there something I can use in a Javascript that will work in Linux?

TIA


I know you can do something like this in Java. (Not JavaScript...
different technology). I have done something where the Java applet
connects to a port (not 80) on the server that the page came from. I am
pretty sure you can get Java to talk to the DOM... though I have never
tried. Java is more platform independant, but still not guaranteed on
all browsers.

Brian

Jul 20 '05 #4

P: n/a
> I would like to serve out a web page (intranet only - no internet)
that has the ability to open a client-side socket that connects to a
server-side socket on another computer. This connection is used to
send data to be displayed using DHTML on the web page (as opposed to
refreshing the entire page).

I have this working where the client is running Internet Explorer in
Windows (the client-side socket is an ActiveX DLL). I would like to
get this to work from a Mozilla browser running in Linux. The ActiveX
stuff, of course, will not work there.

Is there something I can use in a Javascript that will work in Linux?


Yes. I have used <iframe> in IE and Mozilla to do this very thing.
Jul 20 '05 #5

P: n/a
In article <48********************************@4ax.com>,
Martin <ma**********@comcast.net> wrote:
I would like to serve out a web page (intranet only - no internet)
that has the ability to open a client-side socket that connects to a
server-side socket on another computer. This connection is used to
send data to be displayed using DHTML on the web page (as opposed to
refreshing the entire page).

I have this working where the client is running Internet Explorer in
Windows (the client-side socket is an ActiveX DLL). I would like to
get this to work from a Mozilla browser running in Linux. The ActiveX
stuff, of course, will not work there.

Is there something I can use in a Javascript that will work in Linux?

TIA


This page describes a portable method (IE and Mozilla) that works for me:

http://jibbering.com/2002/4/httprequest.html

Jim

--
--------------------------------------------------------------------------------
Jim Buzbee "I was gratified to be able to
jb*****@nyx.net answer promptly, and I did. I
http://batbox.org said I didn't know." Mark Twain
Jul 20 '05 #6

P: n/a
I greatly appreciate the responses to my question - thanks.

I tried using a Java Applet but it seems to be a major overkill for
what I'm trying to do. With an applet, my entire concept changes from
being a web page to being an applet screen. The Java plugin has to be
installed on each client machine (that was a big hassle on my test
Linux machine); and I'd have to learn how to use the Java SDK; etc.,
etc.

I looked at the "iframe" that was suggested. I found a web site that
had a working example of that and verified that it does work on both
the IE/Windows and on the Mozilla/Linux clients. Like the applet
concept, it appears that it would do the job but it's still more than
what I actually need.

I think the same thing is true of the HTTPRequest approach. That is,
it will do what I want to do but it's too much for what I need to do.

Can anyone tell me if it's possible (practical / realistic) to simply
open a socket as the client side of a connection (on a Linux machine)
thru which a small amount of data can be sent to the web page? This is
the approach I'm using now with the Windows machines; I'd just like to
get this to work on Linux boxes.

I downloaded a Javascript from
http://www.phpfreaks.com/phpmanual/p...f.sockets.html but have not
been able to get it to work yet. I don't know if it's even "workable".

Any thoughts?
Jul 20 '05 #7

P: n/a
On Wed, 11 Feb 2004 17:00:18 -0700, Martin <ma**********@comcast.net>
wrote:
I downloaded a Javascript from
http://www.phpfreaks.com/phpmanual/p...f.sockets.html but have not
been able to get it to work yet. I don't know if it's even "workable".


That's PHP, not JavaScript, and it's server-side, not client-side.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #8

P: n/a
On Thu, 12 Feb 2004 00:04:11 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:
On Wed, 11 Feb 2004 17:00:18 -0700, Martin <ma**********@comcast.net>
wrote:
I downloaded a Javascript from
http://www.phpfreaks.com/phpmanual/p...f.sockets.html but have not
been able to get it to work yet. I don't know if it's even "workable".


That's PHP, not JavaScript, and it's server-side, not client-side.

Mike


Example 2 says its client-side.

As to PHP vs Javascript, I'm clueless. Can this be done with
Javascript?

Jul 20 '05 #9

P: n/a
On Wed, 11 Feb 2004 18:26:33 -0700, Martin <ma**********@comcast.net>
wrote:
On Thu, 12 Feb 2004 00:04:11 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:
On Wed, 11 Feb 2004 17:00:18 -0700, Martin <ma**********@comcast.net>
wrote:
I downloaded a Javascript from
http://www.phpfreaks.com/phpmanual/p...f.sockets.html but have not
been able to get it to work yet. I don't know if it's even "workable".
That's PHP, not JavaScript, and it's server-side, not client-side.


Example 2 says its client-side.


It says it's a TCP/IP client. That is not the same as client-side. Even
so, it is still written in PHP which can only be interpreted server-side.
As to PHP vs Javascript, I'm clueless. Can this be done with
Javascript?


No. You'll have to use one of the other suggestions in this thread.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #10

P: n/a
Martin wrote:
I looked at the "iframe" that was suggested. I found a web site that
had a working example of that and verified that it does work on both
the IE/Windows and on the Mozilla/Linux clients. Like the applet
concept, it appears that it would do the job but it's still more than
what I actually need.
Hmmmm.... If IFRAME will work for you, I hardly consider it to be
overkill. It is more portable than what you are currently doing with a
client-side socket, using a Win32 DLL.

Note that you had to use a platform specific mechanism, for sockets,
because the browser did not support sockets natively. This means that
every other browser (Netscape/Mozilla/Opera/Safari/Konquerer/etc) will
all have to have their own platform specific mechanism... yuck.

IFRAMEs are part of the HTML standard, so if you can get it working with
IFRAMEs, I would highly suggest doing so. It is less overkill than an
ActiveX DLL.
I downloaded a Javascript from
http://www.phpfreaks.com/phpmanual/p...f.sockets.html but have not
been able to get it to work yet. I don't know if it's even "workable".


Just a note... PHP is a scripting language, just like Javascript is.
The difference is that PHP is a server-side scripting environment
(similar to ASP or CGI). Basically, you write a script, that the server
executes BEFORE it sends it to the browser. (The server needs to know
how to read PHP) The output of the script must be HTML/Javascript or an
image, or something that a browser can recognize.

By using sockets in PHP, on the server, you can have your PHP script
connect to something, like a database, or some service on another
server, to get data that it formats into HTML, and dynamically sends to
the client. In that sense, it is a client to the service it is getting
it's data from, but as far as the web browser is concirned, it is still
on the server... so PHP cannot be used to create sockets on the web
browser side of things.

I hope this helps a bit. If you can get your application working with
the IFRAME object, I recommend that is what you use.

Brian

Jul 20 '05 #11

P: n/a
>I hope this helps a bit. If you can get your application working with
the IFRAME object, I recommend that is what you use.

Brian


Brian / Michael:

Thanks for the further explanations.

I didn't realize that PHP was so far off from what I needed. I won't
bother persuing that any further.

It does look like the iFrame approach might be my best option.

One thing I don't understand about it yet is: can I "push" data out
from the server to the iFrame target? In my situation, there are
events occurring on the server that create data that I want to display
on the browser's current screen. I don't want the user to have to do
anything to get that data. All I'm doing on the client side (in the
version I have working) is updating the contents and colors of several
cells in a table that is already displayed.

In the example that I played with (that I mentioned previously), I had
to click a button to request some data to be sent from their server.
Is something like that REQUIRED or is that just the way this
particular example was set up?

Thanks again for any additional comments.

Martin
Jul 20 '05 #12

P: n/a
Martin wrote:
I hope this helps a bit. If you can get your application working with
the IFRAME object, I recommend that is what you use.

Brian

Brian / Michael:

Thanks for the further explanations.

I didn't realize that PHP was so far off from what I needed. I won't
bother persuing that any further.

It does look like the iFrame approach might be my best option.

One thing I don't understand about it yet is: can I "push" data out
from the server to the iFrame target? In my situation, there are
events occurring on the server that create data that I want to display
on the browser's current screen. I don't want the user to have to do
anything to get that data. All I'm doing on the client side (in the
version I have working) is updating the contents and colors of several
cells in a table that is already displayed.

In the example that I played with (that I mentioned previously), I had
to click a button to request some data to be sent from their server.
Is something like that REQUIRED or is that just the way this
particular example was set up?

Thanks again for any additional comments.

Martin

Using the IFRAME approach, it is like having a separate page embedded
inside the actual page. The IFRAM can be hidden, so it only exists as
an interface for you, and the user never sees it.

Here is what you do:

On the main page, get your request ready, but do not actually make it
from the main page. Instead, tell the IFRAME to make the request.
Since the user never see's the IFRAME, he will never see the waiting.
Now, the IFRAME can take a long time to respond. When it finally does,
stating that the request is done, your main page can know this, and
alert the user.

You can also tell the IFRAME to check for new data, which will return
quickly. Parse the data out of the IFRAME DOM, and do what you need in
the main frame.

It is not a pushing method, but it is close enough to get what you need.

Brian
Jul 20 '05 #13

P: n/a
Here is a concise discription of iFrame. While on the Apple site, it
does cover the Windows implementation.

http://developer.apple.com/internet/...pt/iframe.html
I haven't used iFrame but could you use an event timer in you javascript
to refresh you html code via dhtml?

Robert
Jul 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.