I am trying to develop a SIMPLE application that should transfer some files to another computer (i.e. from China to UK). I have succeeded some sort of data transfer (using CSocket - a simple way from MFC), but it seems it works only on the local network. and I have absolutely no ideea how to make it work on a wide network.
Can somebody PLEASE help me?
(this is a both Visual C++ (MFC) and a networking thing, so I don't pretty know where it fits)
the connection to the server return an error...
I checked with GetLastError() and returned 10060, which is WSAETIMEDOUT.
one more question I have: how is the client going to find my IP address which is x.x.x.x over the whole internet?
when the client attempts to connect, it has the x.x.x.x ip and the port number, but are they unique through internet? (that's hard to believe)
ok... one thing I found out...
it seems like I used my address from the router (for which, the connection to the other computer connected on the same router worked). I now used my 'real' ip, which should be the one specified here: http://www.whatsmyip.org. now, I don't get 10060 error anymore, but 10061 (WSAECONNREFUSED), and I can't connect at all.
does anybody have an ideea what I can do?
Last edited by Feoggou; September 12th, 2009 at 05:56 AM.
my port nr is 5150
I used netstat -a -n and saw that the ip address is 0.0.0.0:5150 (well, my real ip address I couldn't find, instead I found 0.0.0.0, 127.0.0.1, and the one assigned by the router) which is listening.
with netstat -a I found my_username:5150 LISTENING
by the way... the connection is started on a different thread... it looks like this:
DWORD ThreadProc(CWnd* pWnd)
AfxSocketInit(); //i heard it must be used in every thread.
CArchive arIn(&file, CArchive::load);
the client is a program that has an editbox and a send button. when I push Send, the function it calls is:
// TODO: Add your control notification handler code here
if (m_sEdit.GetLength() == 0)
if (0 == sockClient.Connect(L"my.real.ip address.here", 5150))
DWORD k = GetLastError();
s.Format(L"Could not connect! Error %u", k);
CArchive arOut(&file, CArchive::store);
It sounds like your server may be behind a router/firewall. In this case, you'll need to open a port-forward in your router. If your server is listening on a private network, then it can't be seen from the rest of the Internet without the router handling the transition between your private network and the Internet.
if I did nothing to my computer (my computer is an ordinary computer, I didn't install ISS or anything else) should it anyway work? or do I have to do something? can you please tell me what to do, or give me a link where it is explained?
on the router I had set the start ip = 192.168.2.2 and the end ip = 192.168.2.5 (I have accessed my router with 192.168.2.1). On settings, I chose NAT->Port Forwarding, and inserted ip = 192.168.2.5 (if I insert any ip I wish I get the message "It should be set within the current subnet" - which I understood that my ip must start with 192.168.2, I set the type = TCP+UDP, though I use on my program only TCP. At the port range field I chose the port that I set for my program: 5150.
I have tried the programs on my computer. I have changed for the client, the ip to which it connects. I have tried putting the 192.168.2.5 and it didn't work; I have tried putting my real ip and it didn't work either. I get connection error on client 10060 which is WSAETIMEDOUT.
about ftp... well... I don't know how to use it. and this variant seemed convenient as the file that I will send will rarely have more than 1 MB. The one I tried with had 126 KB. And about sockets, I have more than 0% ideea what it is about; + I need to know how to make a good data transfer (for future). After I will succeed in doing it, I might start to learn ftp.