Solved

Can I open a socket to my own host?

Posted on 1997-11-14
3
199 Views
Last Modified: 2010-04-16
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?
0
Comment
Question by:stouffs
3 Comments
 
LVL 4

Expert Comment

by:russgold
ID: 1230573
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?
0
 

Author Comment

by:stouffs
ID: 1230574
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.
0
 
LVL 4

Accepted Solution

by:
rembo earned 180 total points
ID: 1230575

You can absolutely connect to a socket on from the
host you're on to the host you're on.  Are you
connecting using the same socket calls that you
are using from the client or are you trying to
use localhost?  

It could be a system configuration problem.  If you
post the code, I'd be happy to tell you what's wrong.

Or, you can mail it to me at rembo@cks.com  Or, I could
send you an example where I do it.

-Tony

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JList custom Cell Renderer refresh 15 56
Java Options in Zimbra Server 2 50
servlet  URL Rewriting 1 36
How to execute a Python program and gather return output in Java 2 25
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now