|
I'm trying to develop a two port communication mfc wizard from the basic socket communication program.
Both the ports belong to a single server and the must run parallely.
The application I've made so far is able to connect to the first port.
In the second port connection, server is listening for connections, but the client is unable to connect.
http://www.easy-share.com/1907562869/Sock.rar
Please run the program once. You'll see that only first port is connecting properly, while the second one isn't.
Please provide a relevant solution.
modified on Monday, August 31, 2009 5:13 AM
|
|
|
|
|
Whether both port numbers of single server are same?
What is port number of the second port connection?
Величие не Бога может быть недооценена.
|
|
|
|
|
both the port numbers are different.
i have used 4000 and 5000. both the ports are free.
|
|
|
|
|
Please share your code, so as understand the problem
or
You just check the error you are getting.
Величие не Бога может быть недооценена.
|
|
|
|
|
You're using two socket objects to connect to two different ports or you're trying to use the same? Did the call to connect fail? Have you checked the return values (and called GetLastError() if applicable?)
Can you show us the relevant code?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I'm using only one pointer object but 2 different socket objects.
I tried using 2 pointers, but the second pointer is showing many errors.
main part of the errror is
CSockDlg(CWnd* pParent = NULL); // standard constructor
CSockDlg(CWnd2* pParent = NULL); // standard constructor
errors
c:\documents and settings\admin\desktop\sock\sockdlg.h(34) : error C2629: unexpected 'class CSockDlg ('
c:\documents and settings\admin\desktop\sock\sockdlg.h(34) : error C2238: unexpected token(s) preceding ';'
c:\documents and settings\admin\desktop\sock\sockdlg.h(35) : error C2629: unexpected 'class CSockDlg ('
c:\documents and settings\admin\desktop\sock\sockdlg.h(35) : error C2238: unexpected token(s) preceding ';'
|
|
|
|
|
raviteja2020 wrote: c:\documents and settings\admin\desktop\sock\sockdlg.h(34) : error C2629: unexpected 'class CSockDlg ('
Have you included the correct header file?
That aside, what does any of this have to do with not being able to establish a connection? You need to provide a relevant code snippet.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
if you writing Socket Programs in Win32 Code,
you might have to develop multithread application for creation of Socket Server.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi everybody.
I want to submit a web form. Source of html page:
<html>
<body>
<form action="i.php" method="post">
Name: <input type="text" name="fname" value="MyName" />
Age: <input type="text" name="age" value="17" />
<input type="submit" />
</form>
</body>
</html>
If I submit the form in the page above, I would get:
Welcome MyName!
You are 17 years old.
And this is my code:
CInternetSession session(L"MyAgent");
CHttpConnection* httpcon=session.GetHttpConnection(L"localhost");
CHttpFile* httpfile=httpcon->OpenRequest(CHttpConnection::HTTP_VERB_POST,L"i.php");
CString headers=L"Content-Type: application/x-www-form-urlencoded";
CString data=L"fname=MyName&age=17";
httpfile->SendRequest(headers,(LPVOID)(LPCTSTR)data,data.GetLength());
CString t=L"";
UINT len=100;
char buf[100];
while(len>0){
len=httpfile->Read(buf,100);
if(len>0)t.Append(CString(buf),len);
}
AfxMessageBox(t);
httpfile->Close();
httpcon->Close();
session.Close();
Unfortunately, form is not being submitted. What I'm doing wrong?
I'm trying to do this thing 3rd time now, I don't want to give up this time
Any help would be greatly appreciated.
modified on Thursday, August 27, 2009 6:28 PM
|
|
|
|
|
check your localhost port in the class CInternetSession.
it's my pleasure to make friend with you.
|
|
|
|
|
You probably need to set the Content-Length header.
If I were you, I'd download Fiddler[^] and use it to see what the difference is between the POST sent by the browser in response to that web form and the POST sent by your program.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart Dootson!
I used Fiddler and looks like my program sending data in a different encoding.
Browser is sending:
fname=MyName
age=17
My program is sending:
f[]n[]a[]m[]e[]=[]M[]y[]N[]a[]m[]e
[]a[]g[]e=[]1[]7[]
(Meaning there is a square after each char)
What should I do to send like WebBrowser does?
|
|
|
|
|
Use ASCII rather than Unicode strings, I guess?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you again Stuart Dootson!
It worked
I used CStringA instead of CString.
But, what if I want to send Unicode string? I'll be sending data in russian too.
So is there way to send Unicode too?
|
|
|
|
|
Yes - you need to tell the system what encoding you're using. As far as I can see, that means adding an HTTP header OR something in the HTML document - this Wikipedia page[^] appears to have the details.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I used Fiddler to see what is the browser sending when I typed unicode text.
Web Browser is converting the unicode text into hex values, like
%F2%E8 =ти (russian)
Let me post new thread for this is a different problem(Unicode to Hex conversion).
My problem in this thread is solved. Stuart Dootson, thank you so much!
|
|
|
|
|
Hi,
Created the application same as Windows firewall. In Windows Firewall Under Exception tab we have the "Add Program" button. On click of which the list of program is enumerated. I want to know from where this list is populated. Any registry key under which these programs are listed. or any method to get this list?
Regards.
"A winner is not one who never fails...but the one who never quits"
modified on Thursday, August 27, 2009 2:57 AM
|
|
|
|
|
I sorted through Registry Monitor several times and came up with nothing conclusive. There does not seem to be a registry key/value dedicated to such a list (that would be too easy), but rather a series of cross-referencing from several locations.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thanks for the information.
I looked for NetFwMgr and tried to use the interfaces provided but was not able to get any thing.
INetFwMgr
NetFwPolicy
Thanks
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
The INetFwAuthorizedApplications interface can be used to get the list of applications authorized to open ports in the firewall. This list will be smaller than the list that is shown when the "Add Program..." button is clicked.
Not having done this before, that's all I can offer.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanx david.
I also tried with this... It makes sense if we display that list also. because firewall used add the programs in exception list and not displaying all the applications.
But then also need to find out how does windows get the list of application. I have VS6.0 intalled on my machine and firewall shows most of the application from Visual Studio 6.0 folder from the installed location.
Anyways...Will look to get....
Thanks again for the help.
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
|
hello,
How can we get the proxy setting of a default web browser?
and How to apply these setting on IE?
Thanks...
|
|
|
|
|
I have a problem with this code
CString l_FilePath;
CFileDialog m_ldFile(TRUE,"txt","*.txt",OFN_ALLOWMULTISELECT | OFN_EXPLORER);
m_ldFile.m_ofn.lpstrFilter = "*.txt";
if (m_ldFile.DoModal() == IDOK)
{
POSITION temp = m_ldFile.GetStartPosition();
while(temp)
{
l_FilePath = m_ldFile.GetNextPathName(temp);
m_lstFiles.AddString(l_FilePath);
}
}
Now the problem. i have 8 files in a folder. when i select all the files and try to put the files in a listbox nothing is displaying. but when i am selecting only 7 files then the files are getting displayed. why is that so?
|
|
|
|
|