|
i have not ventured much of socket programming.. so i dont know much about it.. infact i can tell u that it was the first application that i am trying in socket programming. well, when i am trying with one connection it is working. but if i am using multiple connections it is not. i want something like if i send a message then it should reach multiple people.. if multiple sockets can be used then i needs some leads for that.
|
|
|
|
|
Chandrasekharanp wrote: if multiple sockets can be used then i needs some leads for that
Why can't you simply use several different CSocket class instances ? What you did for your example, just do it again with another CSocket instance.
You still didn't answer: how many connections do you need to establish ?
|
|
|
|
|
ok. sorry for that.. right now i want to make 3 connections.
i shall certainly try doing it with ur leads. will get back to you soon..
|
|
|
|
|
Do you need multicast socket??
Look here[^] for example
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
Hey thanks sandip.. looks like this will help me..
|
|
|
|
|
Hi all,
I have a stringstream, and I want to find the index of '<' sign contain in the stream. Actually first content.
<br />
stringstream str("y:<?xml version=\"1.0\" encoding=\"UTF-8\"?><Statistic>");<br />
<br />
int offset = str.str().find('<', 0);<br />
Then I want to remove all the content up to '<' sign and need to make a stream like this.
<?xml version=\"1.0\" encoding=\"UTF-8\"?><Statistic>
Can you help me to do this.
I appreciate your help all the time...
CodingLover
modified on Monday, November 3, 2008 1:53 AM
|
|
|
|
|
Extract the required part by substr() and update streambuffer. Have a look at code snippet.
stringstream str("y:<statistic>");
int offset = str.str().find('<', 0);
str.str( str.str().substr( offset ));
</statistic>
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Ok, thanks.
But how about this way?
str.str().substr(offset)
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: str.str().substr(offset)
str.str() is not returning reference to string. This statement will return back a temporary string object. Hence, It won't update the string stream buffer. For instance,
string temp = str.str().substr(offset);
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks for the explanation.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Always Welcome!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi All
How can i create a New String Value in registry?Like this is path "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Cache".Now i want to create a new string "Name".Plz help me
|
|
|
|
|
You can use of CRegKey Class.
|
|
|
|
|
|
I need to write a function that will calculate standard deviation using an array and possibly a for loop.
my function reads in the array with the values. the number of values, and the average.
where can i start?
modified on Monday, November 3, 2008 1:03 AM
|
|
|
|
|
Dunno really. It's up to you - FindAverage seems like a perfectly suitable name.
Here's how I did it some time back:
#include <math.h>
#include <stdlib.h>
float calcArrayAvg(float *array, long numElements)
{
double tmp = 0;
long i;
for (i=0; i<numElements; i++)
tmp += array[i];
tmp /= numElements;
return tmp;
}
float calcStdDev(float *array, long numElements, float arrayAvg)
{
double thisDev;
double totalDev2 = 0.0;
double varience;
long i;
for (i=0; i<numElements; i++)
{
thisDev = array[i] - arrayAvg;
totalDev2 += thisDev*thisDev;
}
varience = totalDev2 / (float)numElements;
return sqrt(varience);
}
void setArrayMean(float *array, long numElements, float newMean)
{
double oldMean = calcArrayAvg(array, numElements);
double delta = newMean - oldMean;
long i;
for (i=0; i<numElements; i++)
array[i] += delta;
}
void setArrayStdDev(float *array, long numElements, float oldStdDev, float newStdDev)
{
double scale;
long i;
scale = newStdDev / oldStdDev;
for (i=0; i<numElements; i++)
array[i] *= scale;
}
void standard_normal(float *array, long numElements)
{
long i;
double mean, stdDev;
for (i=0; i<numElements; i++)
array[i] = ((float)rand()/(float)RAND_MAX);
mean = calcArrayAvg(array, numElements);
stdDev = calcStdDev(array, numElements, mean);
setArrayMean(array, numElements, 0.0);
setArrayStdDev(array, numElements, stdDev, 1.0);
}
Simon.
|
|
|
|
|
Simon, thank you so much. One thing I noticed though when running tests,
varience = totalDev2 / (float)numElements;
should be
varience = totalDev2 / ((float)numElements - 1);
|
|
|
|
|
Hi,
I am working on an MFC application which has chat feature in which there is an option for sending and receiving smileys.
I am getting the smiley codes. For the respective codes I want to show the bitmap image in a CRichEdit Control.
How to achieve it.
Please help me.
Thanks.
Dhiraj Kumar Saini
|
|
|
|
|
|
|
i want to connect USB WEBCAME in my vc++ application i am using following statment to select driver but i takes some time of processor to select driver which causes to slow speed of my application. and i have to connect and disconnect cammra again and again . can You help me how i can solve this porblem
capDriverConnect(hwnd,0) \\ use for default driver
or is there any method through which i have to select driver just once and i may able to change handle of frame with that driver without disconnecting cammra
|
|
|
|
|
The index selects the driver.
Connecting and disconnecting is going to be slow no matter which
driver you select.
What do you mean "change handle of frame"?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I want to add a Colour Picker Button to my Project. I am using VC++6.0 IDE and MFC.
I have found this nice Demo by Chris Maunder of exactly the sort of button I want to add to my dialog.
http://www.codeproject.com/KB/miscctrl/colour_picker.aspx
The demo compilies nicely and runs fine.
Indeed I can add the source files to my own project and compile fine too .
The understanding I am stuck with is how to add this custom control to my own dialog using the Resource Editor . Is there a way of adding it to the controls pallete or does it have to be added some other way ???
|
|
|
|
|
Since that particular control subclasses an existing button, put a button on the dialog and then subclass it as explained in the article.
|
|
|
|
|
I'm trying to understand exception handling in C++.
void main()
{
try
{
ios_base::open_mode d;
ofstream myfile;
myfile.open ("example.txt", d);
cout << "No excpetion thrown?" << endl;
system("Pause");
}
catch (exception& e)
{
cout << "ERROR:\r\n" << e.what() << endl;
system("Pause");
}
}
All I want to do is catch the exception with the general exception class.
I did enable C++ Exceptions in the project properties (/EHsc) but when debugging the exception (uninitialized variable 'd' and there is no file called "example.txt" either) isn't thrown because the application is interrupted by MSVC++.
However, the release build simply executes without any exception at all.
I want to use a general exception to catch all errors, in case something unexpected happens and I don't want to use catch(...) because I want to use the what() function to get some information about the error that occurred.
How would I go about it correctly?
Thanks in advance.
|
|
|
|