aspose file tools*
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 Java 8 in Action this week in the Java 8 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
Author

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
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Connect to self the long way
 
Similar Threads
publishing the server
web services interoperability
Socket/sersocket - connecting to server without knowing address
run .bat file from client machine of deployed web application on server machine
Can I Have Two-Way Communication with Sockets with just one Port?