Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Sockets, Javascript and Java

Thread view: 
j_macaroni@yahoo.com - 10 Jun 2006 22:35 GMT
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
IchBin - 11 Jun 2006 03:55 GMT
> I know Javascript has no methods to directly open sockets.
>
[quoted text clipped - 5 lines]
>
> 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_macaroni@yahoo.com - 11 Jun 2006 04:09 GMT
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

> > I know Javascript has no methods to directly open sockets.
> >
[quoted text clipped - 30 lines]
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor,  Regular Guy (1952-)
Paul Hamaker - 11 Jun 2006 10:37 GMT
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.
--------------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com
j_macaroni@yahoo.com - 12 Jun 2006 03:14 GMT
That's ok, since the connection would be on the originating host. Would
you know where I can source code that implements socket communications.

> 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.
> --------------------
> Paul Hamaker, SEMM, teaching ICT since 1987
> http://javalessons.com
IchBin - 12 Jun 2006 04:35 GMT
> That's ok, since the connection would be on the originating host. Would
> you know where I can source code that implements socket communications.
[quoted text clipped - 5 lines]
>> Paul Hamaker, SEMM, teaching ICT since 1987
>> http://javalessons.com

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-)
IchBin - 12 Jun 2006 04:36 GMT
> That's ok, since the connection would be on the originating host. Would
> you know where I can source code that implements socket communications.
[quoted text clipped - 5 lines]
>> Paul Hamaker, SEMM, teaching ICT since 1987
>> http://javalessons.com

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-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.