Solved

Can I open a socket to my own host?

Posted on 1997-11-14
3
178 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

708 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

16 Experts available now in Live!

Get 1:1 Help Now