|
In asynchronous mode, you shouldn't be continuously calling WSASend or WSARecv , but instead you're supposed to issue only one call to WSASend (WSARecv ) after being notified with FD_WRITE (FD_READ ). Check your documentation for WSAAsyncSelect . Also, you might want to take a look at Warren Young's Winsock Programmer's FAQ.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks.
I am developing the program under WindowsXP and Athlon 750mhz.
I am very, very close to getting everything working as planned. Here is my progress. The program sends data perfectly (I believe). For example:
// Given WSABUF dataHDR, dataMessage
- send header buffer (dataHDR.Buf = data size)
- send data buffer (dataMessage.Buf = message)
// Given WSABUF inHDR, inMessage
- receive header buffer (inHDR = data size)
- use atol() to convert inHDR.Buf into an integer data size
- receive data buffer (inMessage.Buf = message)
Okay. I checked the actual receive size after calling WSARecv for the data buffer. The receive size is accurate, i.e. it received the exact number of byte that was sent. However, I cannot extract all characters from inMessage.Buf.
I use this code to extract the characters from inMessage.Buf
// CString message;
// message += *inMessage.Buf
The problem is the code above only extracts the *first* character in inMessage.Buf. I have considered that maybe only one character or byte is inside of inMessage.Buf; however, according to the check I did above on the actual received size, everything seems accurate.
Am I not converting inMessage.Buf correctly?
Kuphryn
|
|
|
|
|
Can some please tell how I can get a list of the available drives on a system (preferably CD drives). Is there an iteretor that I can using or something like that?
thanks,
Vic
|
|
|
|
|
Use GetLogicalDriveStrings to get a list of the drive letters.
Then use GetDriveType and check the return value for DRIVE_CDROM.
Like it or not, I'm right.
|
|
|
|
|
|
Can some one please tell me a simple method for setting the min values for the resizing of a dialog box (i.e. the box cannot be resized any smaller)
I know there is a way by changing the GetMINMAXValues function, but I somehow wasnt able to implement it.
Thanks, Vic
Vic
|
|
|
|
|
You could handle the WM_SIZE message and change the values if they are too low.
Like it or not, I'm right.
|
|
|
|
|
Use SetWindowPlacement with WPF_SETMINPOSITION.
|
|
|
|
|
ok... in this code... you dont have to worry where everything is being defined or what headers im using,... wheres my functions... this is just the main program... It all works the first time through, then, the cin stops working:
int main()
{
for(;;)//main loop
{
gets(SName);
cin >> SGPA;
person.SetName(SName);
person.SetGPA(SGPA);
cout << person.GetName() << endl << endl; //print name that you just typed.
for(int inc = 0;inc < NN;inc++) //print all names.
{
cout << Names[inc] << "\t" << GPAS[inc] << endl;
}
inc = 0;
}//end main loop.
return 0;
}
in the program is waits for input for the name of sombody... then it goes on to the next thing... which is my cin statment, asking for the float "GPA" of the persons name you put in. after the first time you run through the on going loop... your not able to insert a GPA, rather, for every new name you put in... it applies the original GPA to the names.
Q~How do i reset my cin or get it to work everytime in the loop. set it to null?
Thanks!
~SilverShalkin
i have a fealling that it might not be the cin but i'll see in a bit
|
|
|
|
|
cin.flush() should solve your problems, I reckon.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
CString str = "8000";
doulbe dbl;
dbl = atof( str );
dbl = dbl / 1000;
str.Format( "%d", dbl );
MessageBox( str );
Should that output 8, or is it wrong?
-Raffi
|
|
|
|
|
It is wrong.
When you say %d str.Format expects an integral argument 4 bytes wide. Double is 8 bytes wide so str.Format takes the leading 4 bytes and displays it thinking it to be a valid integer.
|
|
|
|
|
you are correct!
str.Format( "%d", int (dbl) );
is ok!
|
|
|
|
|
Use %f instead of %d
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Raffi wrote:
doulbe dbl;
Am I the only one that noticed 'doulbe' or did everyone just disregard that as an error while typing the post?
|
|
|
|
|
I just regarded it as an error - his compiler would report it, and if he couldn't figure that out, he should probably move to Logo.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Does anyone know how I can open a file with iostreams and get it's size without first writing to it ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Probably seek to the end and get the position. that would be the size.
|
|
|
|
|
After I posted, it occured to me: I'm opening an ofstream because I only want to write, and so I need to write before I have a position, but if I open an fstream, I can probably do a read to get that info without writing anything....
thanks.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Just out of curisoity why do you need the file length when you are writing to it? Do you want to append? In that case ios::app would be good enough (But I don't think that you would miss that).
|
|
|
|
|
Nope - what I want is to know when the file hits 10k so I can archive it and start a new one.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Open the file, call tellg , go to the end of the file with seekg(0,ios::end) , call tellg again and calculate the difference.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi All,
I've got a CFormView derived view that I need to be able to add some fancy edit controls to at run time. Based on some input from the user, I will have what's essentially a set of edit controls inside a group frame, with anywhere from say 1 to n edit controls, but I won't know how many until runtime.
So, I was guessing this might involve calling CreateWindow directly, but not too sure. The edit controls are actually edit derived ActiveX controls, that do some additional stuff on top of the basic edit control stuff. I remember seeing some sample somewhere for something like this, and it seems like you called CreateWindow and pass in the progid of the control somewhere, but I can't remember the details.
Anyone done something similar?
Thanks,
Aaron
|
|
|
|
|
Typically, you'll have an array of pointers to CYourEdit s. After constructing this array with something like:
m_array=new CYourEdit*[m_nControls];
for(size_t n=0;n<m_nControls;++n)m_array[n]=new CYourEdit(); you'll have to create each of the controls. The actual creation method depends on the type of the controls, but chances are you have to pass the parent window, the rectangle the control is enclosed in and a control identifier (use 0xFFFF .)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How do copy a CString to a BSTR and vice versa?
|
|
|
|