yeah...
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:
the client is a program that has an editbox and a send button. when I push Send, the function it calls is:Code:DWORD ThreadProc(CWnd* pWnd) { CSocket sockServer; AfxSocketInit(); //i heard it must be used in every thread. sockServer.Create(5150); sockServer.Listen(); //sockServer CSocket sockConnection; sockServer.Accept(sockConnection); CSocketFile file(&sockConnection); CArchive arIn(&file, CArchive::load); arIn.ReadString(retValue); pWnd->SetDlgItemTextW(IDC_EDIT1, retValue); arIn.Close(); file.Close(); sockServer.Close(); return 0; }
did i write it wrong?Code:void CSKClientDlg::OnBnClickedOk() { // TODO: Add your control notification handler code here UpdateData(); if (m_sEdit.GetLength() == 0) { MessageBox(L"Nothing written!"); return; } CSocket sockClient; sockClient.Create(); if (0 == sockClient.Connect(L"my.real.ip address.here", 5150)) { DWORD k = GetLastError(); CString s; s.Format(L"Could not connect! Error %u", k); MessageBox(s); return; }; CSocketFile file(&sockClient); CArchive arOut(&file, CArchive::store); arOut.WriteString(m_sEdit); arOut.Close(); file.Close(); sockClient.Close(); MessageBox(L"Information Sent!"); }




Reply With Quote