• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

internet messenger

i'm trying to build a small messenger application, peer-to-peer, very simple, using window sockets.
the thing is that is working when i'm using a real ip.
but when i test it from a lan, i cannot connect to the other peer if i'm passing through a proxy.

is there a posibility to program the application to work through a proxy?
if i'm in a lan, and i have a c application which start a listening server on any port (3333 for example), can i access this port from outside?

sorry if my questions seem stupid, but i don't know so much about networks...

so i would appreciate any suggestion, explication, etc...

2 Solutions
It could be that you are connected through a proxy or a firewall which is blocking the port 3333. In that case you will have to open the particular port. Please give more info on the type of network you are in and what is the proxy/firewall that is being used there?
cmaryusAuthor Commented:
first, i don't know much about the proxy/firewall used on my network (i'm accesing the internet from office).
what i want is to design a solution that could work through a proxy, not necessarily the case i described above.
To start with, heres an example scenario of an established chat session when your program is working in the future:

Incoming packets destined for your chat program will come from the Internet and hit a firewall. If port 3333 is opened up on the firewall then it will pass them through and it will consult its rule table to identify the appropriate machine to forward the packets on to. If port 3333 is closed on the firewall, then the story ends here. You need to make sure the port is open for this to work.

It will forward them to the proxy server which will consult its list of exisiting connections and it will see from the source IP that the chat packet is part of a session destined for your workstation, and forward the packet on to you. Your workstation will recieve the packet and the from IP will read as the external IP of your chat-mates' network (or his direct IP if he is on a modem to the Internet).

That scenario is the most normal one.

You need your software (I'm no programmer so I'll generalise) to be aware of proxies. In Internet Explorer, Firefox, RealPlayer and any other proxy-aware program that exists, you have to tell the program the address of the proxy server. So I'm guessing that when the program knows it is using a proxy, it send the packets out specially formatted, or instructs the appropriate part of the operating system that creates packets on its behalf to do so - to be honest I don't know how packets get made* I just make servers work!

*A mummy packet and a daddy packet have a 'special hug' and then 9 processor cycles later a little baby packet is made?

In the most basic terms, an IP packet consists of a packet header and the data it is carrying. The header holds the destination IP and the source IP.

Theres more to it than that, for example the header contains information about which packet this one is in the sequence and all sorts of other cool stuff. You might find these pages helpful:


But that page looks mighty dull, I'd suggest lookign for packet structure info on the Internet.

For your chat packets inside a network with a proxy, the Proxy server would be the destination IP because they have to go there first, and your workstation would be the source IP, so there must be some clever way of letting the proxy know the 'real' destination IP which is the IP of your Chat-mate on the other side of the Internet. It must be hidden in the packet header because the proxy doesn't care about the data segment, and wont look in there. It is merely a middle man.

I'm guessing there will be programming resources out there (or the programing sections of EE I suppose) where you can find out about how to control the structure of a packet, or steal some code where someone has already done it.

I hope that helps,

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MOst of the Proxy/Firewalls Uses PAT or NAT technique.

You can programm ur application to work with port 80 and 1080 bcoz mostly Proxy/firewalls are used for internet sharing which works with port 80 and some times they are used to allow traffic from socks port 1080.

so try it It may help you .

we can only give you an idea bcoz we are network engineers not the programmers.

It will be good if you post a copy of this question in programming section. Might be you get some help from there.
cmaryusAuthor Commented:
thank you so much for the explanation.
i will try to put a link to this question on the programming section.

i won't close the question yet, because i might come back with another questions.

for now:
joesinc: i get it: in order to acces an external ip, i have to go through proxy. i will use a sniffer to see how does my browser connects through the proxy...

joesinc, iwontleaveyou: if i would start a listening server on port 80, is it possible that an external ip could access my server, through proxy of course...
Right, if you want people to send requests to your internal machine on port 80, then you need your firewall to know what incoming requests on port 80 are permitted and also it must know where to send those packets on to.

So if you get can get your hands on the firewall configuration you could program it up to forward port 80 packets. But a lot of corporate environments already have port 80 in use for a website they serve. But that doesn't matter cos there are lots of ports to go around and you can switch back to 3333 or whatever you like.

My explanation earlier was a bit wrong actually. Outgoing packets from your client go via the proxy and then on to the firewall and out to the Internet as I said, but the responses come back to the firewall and the firewall would be configured to route packets directly to your PC. They COULD be routed back in via the proxy but MS Proxy server and ISA server don't have the capacity to re-route packets on to teh correct PC (at least I've not done that before) so you might as well just tell the firewall to route packets to your PC.

Of course you are then exposing port 3333 on your PC to the Internet, so you need to make sure your software doesn't have any dodgy unchecked buffers etc!

cmaryusAuthor Commented:
i agree about spliting the points. sorry, but i haven't got time to work on this part...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now