Sockets, Javascript and Java

J

j_macaroni

I know Javascript has no methods to directly open sockets.

Since that is not possible, I was wondering if anyone knows of a Java
applet
somewhere that does this that can can be instantiated in Javascript.
This would
be running on a Windows client under IE or Firefox.

Thanks
 
I

IchBin

I know Javascript has no methods to directly open sockets.

Since that is not possible, I was wondering if anyone knows of a Java
applet
somewhere that does this that can can be instantiated in Javascript.
This would
be running on a Windows client under IE or Firefox.

Thanks

I think you could use PHP to open a socket. Thia would be a better
approach to the problem.

function socket_raw_connect ($server, $port, $timeout,$request)
{
if (!is_numeric($port) or !is_numeric($timeout)) {return false;}
$socket = fsockopen($server, $port, $errno, $errstr, $timeout);
fputs($socket, $request);
$ret = '';
while (!feof($socket))
{
$ret .= fgets($socket, 4096);
}
return $ret;
fclose($socket);
}


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
J

j_macaroni

Problem with this approach is that PHP would have to be started via an
HTTP request.

This means a PHP page would be on the server. However since this is
using HTTP and requests/response are not persistent where you can have
a two way <send><receive> without closing and reopening the socket.

Java seems to be the best choice that can communicate with the browser
without having to install anything on the user's computer.

Thanks
 
P

Paul Hamaker

You could code an applet to connect to the originating host using
sockets, but if you want it to connect elsewhere on the net, it will
have to be signed and the user will have to consent.
 
J

j_macaroni

That's ok, since the connection would be on the originating host. Would
you know where I can source code that implements socket communications.
 
I

IchBin

That's ok, since the connection would be on the originating host. Would
you know where I can source code that implements socket communications.

Paul said:
You could code an applet to connect to the originating host using
sockets, but if you want it to connect elsewhere on the net, it will
have to be signed and the user will have to consent.

Generally Here:
http://java.sun.com/docs/books/tutorial/networking/index.html

Specifically here:
http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

Some samples to get going:

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
I

IchBin

That's ok, since the connection would be on the originating host. Would
you know where I can source code that implements socket communications.

Paul said:
You could code an applet to connect to the originating host using
sockets, but if you want it to connect elsewhere on the net, it will
have to be signed and the user will have to consent.

Generally Here:
http://java.sun.com/docs/books/tutorial/networking/index.html

Specifically here:
http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

Some samples to get going:
http://javaalmanac.com/egs/java.net/CreateClientSocket.html

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
Joined
Apr 26, 2009
Messages
1
Reaction score
0
You can achieve "real" sockets in JavaScript by including an invisible Java applet or Flash movie that interfaces with JS.

I chose to use Java because handling <policy-file-request/> queries in Flash is a pain, and sometimes impossible if you're trying to connect to a domain other than the one on which you are hosting the movie.

Here is the tool I created. Hope it helps!
stephengware.com/proj/javasocketbridge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top