|
There are many way's in VC++ to deal with communication with socket
1.Try the ActiveX WinSock { if u have demo project , i did not get one}
2.Use the CSocket Class {easy to use }
3.Use CAsyncSocket which is the base class for CSocket
4.Driectly use the " SOCKET " provided in windows.
Sockets are very difficult to handle in Multiple Client and Server System
try to use WinSock
I have pasted a small raw code so dont copy past it use the funda from
this code .Actually we create two socket we Bind the first on and set it
on listining mode .When a client arrives we use another socket to communicte
through that client .Remember first one is yet in listening mode. Use the
Multithreading concept if u are using MFC .
//->--------------
#define SERVER_SOCKET_ERROR 1
#define SOCKET_OK 0
{
CSocket s,a;
s.Create();
SOCKADDR_IN sin;
sin.sin_family = PF_INET;
sin.sin_port = htons(6000);
sin.sin_addr.s_addr = INADDR_ANY;
//bind the socket
s.Bind ( (LPSOCKADDR)&sin, sizeof(sin));
if(rVal == SOCKET_ERROR)
{
socketError("Failed bind()");
WSACleanup();
return SERVER_SOCKET_ERROR;
}
//get socket to listen
s.Listen (1);
if(rVal == SOCKET_ERROR)
{
socketError("Failed listen()");
WSACleanup();
return SERVER_SOCKET_ERROR;
}
s.Listen (1);
s.Accept (a,NULL,NULL);
s.Send ("hi",3);
if(s.Connect("10.0.0.17",6123))
{
int i=0;
while(i++<10)
{s.Send(m_text,m_text.GetLength());
m_text = "";
char buff[17];
int i;
while(m_text.Find('\n') == -1)
{
i=s.Receive(buff,16);
buff[i]=0;
m_text += buff;
}
AfxMessageBox(buff);
}
// m_text.Trim();
//UpdateData(false);
}
s.Close();
}
//->----------------------------
Hope this solve your need
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
why do u not download the sample code from MSDN : ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vcsample/html/_sample_mfc_CHATSRVR.htm
give a hand,have a heart
|
|
|
|
|
|
|
sunit5 wrote:
Thanx a lot to everyone
Why Do u need to use CSocket in your Project! any particular reason. from you previous post here, you are using raw socket api in your project/software!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
1- Suppose we have installed hebrow and arabic languages on an english version of windows. I have written a windows API program that has some text in arabic, some in hebrow and some in english to be shown on client area of my window. WITHOUT DEFINING UNICODE how can I notify Windows that This text should be shown in Arabic and that text should be shown in hebrow? perhaps by notifying Windows the code page of the text to be shown.
2- How can I change font and language of a Dialog Box with runtime functions?
3- How can I trap WM_INPUTLANGCHANGE in the dialog box procedure? this message is not sent to the procedure.
Thanks a lot
|
|
|
|
|
Hello. I was wondering what is the algorithm used by outlook express to encrypt the password for the stored accounts. (I lost the password for a very important account of mine ;-( ) Please help.
|
|
|
|
|
If I were you, I'd just request a new password from the mail provider.
There's little chance that the password is encrypted in a way that you can easily revert it to the original from what is stored, even if you knew the algorithm they use.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
gecool wrote:
I was wondering what is the algorithm used by outlook express to encrypt the password for the stored accounts.
Outlook express doesn't encrypt the password when it store it, i myself retrieve it some time before but I forget how to do that!, I believe the Search should start from registry!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
thankz, first... i figured out the key where the password is stored, but since i don't know the algorithm used i don't know how to decript it. It possible to do it since out there on www are available a bunch of appz destined to recover the outlook password. I just want to find out the encryption algorithm used to store
the password in the registry
|
|
|
|
|
gecool wrote:
I just want to find out the encryption algorithm used to store
the password in the registry
This Link Will Help
Accounts Password[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Did not ... but they (Micro$oft) weren't suppose to reveal their own secret, were they ?
|
|
|
|
|
gecool wrote:
they (Micro$oft) weren't suppose to reveal their own secret, were they ?
May Be
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi Friend,
I am using the socket client in my application and performing the operation based on input from server.Now if server send the disconnect cmd to client my application hang. Can anyone please let me know the reason of this and how to resolve it?
Thanks
|
|
|
|
|
itkid wrote:
Can anyone please let me know the reason of this and how to resolve it?
Try posting more details... What does "my application hang" mean exactly? Entered an infinite loop? Crashed with an exception? Where? In what part of the code? etc.
Otherwise, if you ask vague questions you'll obtain little more than vague responses, as in the following:
Q: My application has a problem. What's the reason?
A: The reason for 'a problem' is 'there is something wrong'.
Q: How can I resolve it?
A: The way to resolve it is just fixing whatever is wrong.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
|
i have edited my toolbar icons in my project. i inserted a new image. when i run the program, it is disabled...so i changed the ID to an appropriate name then made function in Mainframe...it became enabled but still doesnt work...
how can i insert a command for that icon so that it will be enabled and perform a specific function.
thank u..
|
|
|
|
|
htv22 wrote:
how can i insert a command for that icon so that it will be enabled and perform a specific function.
just double click on it or enter the classWizards and select ur toolbarbutton(look for the id)
and edit the code...
/\|-||\/|/\|)
|
|
|
|
|
Use the ON_COMMAND message map to perform the specific operation on the toolbar button.
|
|
|
|
|
I have created a Explorer type application in which i have problems in viewing the large icons.When i update the List view to display the files and folders in a particular path i am getting only the text display not the image.
Any suggestion or article of this kind will be helpful
Thanks
|
|
|
|
|
If i understand u correctly u want to add an icon for ur tree component.
U can choose between the two function i worked on before.
the first function is for getting the icon from ur computer(The one specified in the folder option FileTypes Tab)
HICON CMyTreeCtrl::GetIcon(CString pathFileName)
{
// Call SHGetFileInfo to get the icon. Call with dummy filename and
// SHGFI_USEFILEATTRIBUTES flag, so file doesn't actually have to
// exist.
SHFILEINFO shfi;
memset(&shfi,0,sizeof(shfi));
SHGetFileInfo(pathFileName,
FILE_ATTRIBUTE_NORMAL,
&shfi,
sizeof(shfi),
SHGFI_ICON|
SHGFI_USEFILEATTRIBUTES|
SHGFI_SHELLICONSIZE |
SHGFI_SMALLICON);
return shfi.hIcon;
}
And the second one if u want to customizeur own images:
First create the icons then Create an imagelist and do the following
m_imageList.Create(16,16,0,3,2);
m_imageList.SetBkColor(RGB(255,255,255));
HICON hIcon;
hIcon = AfxGetApp()->LoadIcon(IDI_ICON2); //Folder eg
m_imageList.Add(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON3); //File eg
m_imageList.Add(hIcon);
m_T.SetImageList(&m_imageList,TVSIL_NORMAL);
I hope this helps
/\|-||\/|/\|)
|
|
|
|
|
Thanks for your reply.
What exactly my problem is when i clicked the LARGE ICON Button on the applications tool bar or select it from the View menu the Icons are not getting displayed in the List view. I am able to see the icons in other views namely Details,Small Icons ,Lists. There's absolutely no problem with the tree view.
|
|
|
|
|
I think you probably didn't load/set icons for large view, did you?
- NS -
|
|
|
|
|
How to arrange message sending and getting for example in MDI windows forms app I need to send a custom message WM_USER+1 or something from child to parent and to get it in parent. Something like in VC++ ON_MESSAGE(...) macro is it possible in windows forms, please give a snippet of code
9ine
|
|
|
|