We help IT Professionals succeed at work.

Peer to peer tcp connection

vidz7
vidz7 asked
on
Hi experts

I want to do the following, please tell me if it's possible.

i hv written a messenger in java and now need to implement File Transfer. Say ClientA wants to trasfer a file to ClientB. What i was thinking of doing was to make ClientA open a ServerSocket and wait for ClientB to connect. ClientB will be given the IP and PORT of ClientA by a server in between. Once ClientB gets the IP/PORT of ClientA it creates a new socket and connects to ClientB. After the connection is established, ClientA pushes the file to ClientB.

i need to know

1) Will this work if ClientA is NOT behind a firewall but ClientB is.

2) What happens if ClientA is behind a firewall and ClientB isn't

3) What if both are behind a firewall

4) If ClientA accesses the internet through a router and has a static IP assigned to it in the intranet, what IP will ClientB need to have to access ClientA. Basically how will the IP be resolved?

Thnx in advance
vidya
Comment
Watch Question

Commented:
This will work if ClientB "can" connect to ClientA. Normally, that means ClientA must have a "real IP" and the port it's listening on is not blocked by the firewall. At the ClientB's side, that means ClientB is allowed to make an outgoing connection on that port (to the host of ClientA).

1. Yes, if the firewall doesn't block the outgoing connection from ClientB on that port/host.
2. Yes, if ClientA has a real IP (the firewall using NAT forexample) and the port is not blocked. No, if ClientA connects to the internet through a proxy (ClientA has no IP on the internet) or the port is blocked.
3. Yes if both 1 and 2 are "Yes".
4. Normally, ClientA doesn't send the IP to ClientB. The server will send it (to prevent ClientA from tricking ClientB). When ClientA connect to the server, the server will know its IP. Again, if ClientA has an IP in the intranet, but it has no IP in the Internet (realIP), this won't work, because the IP the server sees will be the IP of the firewall (or gateway).
This question is LOCKED with a Proposed Answer.  If it helps you, great, accept it and grade it to close.  If not, reject it and comment as to why or what else is needed.

Few additional experts will join this collaboration effort, once a question has been locked.  Just want to confirm this to you.  If more than one expert helps you, you can always split points or award additional help in a new question, within the same topic area.  If you need help from us, post a zero point question here, and include the link:

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

Moondancer
Community Support Moderator @ Experts Exchange

Commented:
where is vidz7 ?
vidz7 logged in days after I posted this request and chose not to respond so I will force accept this to close it.  I can only assume that your information served the need.

In the event Asker returns with additional needs here, please respond.

Thanks,

Moondancer
Community Support Moderator @ Experts Exchange
how to resolve the fourth of the questions posted by vidz7??????

Explore More ContentExplore courses, solutions, and other research materials related to this topic.