File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Connect to self the long way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Connect to self the long way" Watch "Connect to self the long way" New topic

Connect to self the long way

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I have a client that opens a Server Socket and leaves it open all day. At some point, another machine can open a connection and send some messages. Some users have firewalls that prevent this from working. I'd like to detect this at client login, and I'm thinking I'd like the client to connect to itself. Probably a dummy question: Is there a syntax for my local port that forces a connect to it to go out through the network and back? Thanks!!

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Nope, don't believe so.

Why not just have the server try to connect to the client as soon as the client connects to it?

[Jess in Action][AskingGoodQuestions]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
That's high on my list right now because I haven't gotten into the books to look at how the client can call itself through the firewall. The normal use of this thing is async - one client broadcasts a message through the server to a subset of other clients matching some grouping criteria. Using the server to contact the client and report the results would be synchronous. That's not a problem even though it takes 30 or 60 seconds to fail, but it would be a new service. We also get some concern about bandwidth needs at logon from an offshore site. If it's the only way to do it, then so it goes.
I agree. Here's the link:
subject: Connect to self the long way
It's not a secret anymore!