Link to home
Start Free TrialLog in
Avatar of stouffs
stouffs

asked on

Can I open a socket to my own host?

I have a server application that serves communication between different applets. I will call this the exchange application. These applets can connect to my application through a socket and send a message to any other applet connected to this exchange application. This part works.

I would like to be able to access this application not only over the net but from other applications running on the same host. In fact, I have implemented a few (CGI) Java applications that are invoked on the server as a result of an HTTP request. I am trying to create a socket from one of these applications to my exchange application.

However, the socket fails to create. Can I create a socket to the same machine? Otherwise, it may also be possible that my web server (Oracle database web server) does not allow me to create any sockets.

Is there any other way, I might be able to have these two applications communicate other than through a socket?
Avatar of russgold
russgold

Yes you can open a socket to your own host, as long as you actually download the applet using http:/ protocol, just as though you were on a different machine.  If you use file:/ protocol, the browser will not allow the connection, even though you are connecting to the same machine.

If you are already doing this, can you post a section of code that shows how you are trying to connect and what result you are getting?
Avatar of stouffs

ASKER

I'm not actually running an applet in this case, instead I'm running a CGI Java application. Thus it's not up to the browser to allow the connection, but up to the web server.

Unfortunately, I'm not getting any result. I catch any Exceptions thrown, but it never gets to this point.
ASKER CERTIFIED SOLUTION
Avatar of rembo
rembo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial