Click here to Skip to main content
15,918,211 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can I implement an Network program use on the two different subnets using Java Socket? Since there is a router, How can the client connects the passive server?
Posted
Updated 16-Dec-10 9:59am
v2
Comments
Abdul Quader Mamun 16-Dec-10 15:59pm    
Spelling Check.
Richard MacCutchan 17-Dec-10 3:20am    
Reading some of your comments below, you appear to have a basic misunderstanding of network routing. As I said in my response, if there is a route from client to server then a socket connection should succeed. If there is no route then there is no way to communicate; you cannot bypass the router - that is part of the route.

Have a look at this[^] for the basics. I can't vouch for its accuracy, nor for its currency, but it ought to give you a starting point.
 
Share this answer
 
Comments
luckytree2011 16-Dec-10 16:56pm    
If the passive ServerSocket is located in LAN, the client is loated in other LAN, can the client connect to this passive Server?
Marc A. Brown 16-Dec-10 18:35pm    
I don't know; however, someone else may be able to answer. Also, you could test it out yourself by setting up your client machine on a different subnet than your server, couldn't you?
luckytree2011 16-Dec-10 19:17pm    
I did the test already. It couldn't work. Since the server is located in the Local Network, the client request messge would be dropped inside the router because the router couldn't determine the destination of this reques message inside the Local Network.

There is one solution is to open the port inside this router, but this solution is not what I want. I want my program (client which is located in LAN) can bypass the router and connect to the server (Which is location in other LAN). Do you guys know how to do it uses WinSocket or java Socket?
Marc A. Brown 16-Dec-10 21:59pm    
As Richard said in his answer,if there's a valid route between the machines, what you're wanting to do should work. Can the machines "see" each other (i.e. can you ping one from the other)? Anyone else reading this, feel free to jump in with suggestions.
Sockets communicate from IP address to IP address, as long as there is a network route between the two then your program should work. Perhaps you need to clarify the problem you are encountering.
 
Share this answer
 
Comments
luckytree2011 16-Dec-10 16:55pm    
If the passive ServerSocket is located in LAN, the client is loated in other LAN, can the client connect to this passive Server?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900