I am creating a server application using CAsyncSocket , i am able to recieve information from a client , how could i send reply back to connected client , at present i am able to accept only one client how could i make it for multiple clients...
this is code that i had written...
here async is a class derived from CAsyncSocket....
void async::OnAccept(int nErrorCode)
if( recvsocket==NULL )
recvsocket = new async;
//Create the new connection
if( Accept( *recvsocket,NULL,NULL ) == 0 )
here i declared recvsocket as
in the async class....
void async::OnReceive(int nErrorCode)
char *pBuf = new char;
int iBufSize = 1024;
int iRecv, iErrCode;
CString strRecv, Emsg;
When I check in process viewer the class priority is "Very High", the thread priority remain "normal". Also when a thread runs in "my.exe" it's not given the highest priorities, i am free to access other programs.
Hi Ant, my application is time sensitive. even mouse move will affect its normal operation. This is why i have to suspend other programs when my exe run a thread.
Actually i found a standalone program in the net that list out all the running programs (I give you the link asap). When i set the priority to real time (24). I found my program running fine while i cant even access the mouse.
Well, just a notice - Windows are not realtime OS, if you really need the RT features (for RT controlling a device or something like that) you better to go by some specialized RT OS or get some RT plugin for NT that replaces the standard scheduler.
Even if you set the process realtime priority and thread realtime priority the time scheduler can interrupt your process and will do it usually in the worsest possible time.
Apologies if this has already been covered but I could find it anywhere.
The problem that I have is that a piece of software that I am working on used a lot of arrays and matrices (i.e. float* and float**), the problem that we where having was that the program was leaking memory like there was no tomorrow (about a meg every 10secs) and the program was crashing at 'innocent' parts of the code.
After spending quite a while trying to solve these errors I decided to go at it with a sledge hammer and change all of the arrays and matrices to STL vectors (i.e. vector for the arrays and a vector <vector> for the matrices). I've now finished making the changes and the program no longer leaks memory or crashes, however it now runs at about 50% slower. I've changed where the vectors are created so that they are only created once. This has improved things quite a lot however it is still noticibly slower about 10%, does anyone have any other easy optimisation methods that I can implement.
I've left the way that the program accesses the data the same using the  and  brackets.
Any thoughts or suggestions will be gratefully received!
cheers for your reply, I think I have now located where the bottle neck in the code is! basically we copy a BYTE array (about 23000 elements each time!) into another vector (of type unsigned char) about 20-25 times a second which is slowing the whole process down so I'm now currently looking at optimising the copying process
well, I think that if speed is important, you should go back and figure out why your application is leaking memory ... if using VC++ compile in debug mode, and use the DEBUG_NEW define macro to help you find where exactly is the leak; and/or use BoundChecker or some other 3rd party software helper to find te leaks.
you found ( from you other post ) that you copy a lot of arrays, maybe that's where you are leaking memory ...
remember that for each new there should be a delete and for each new  there should be a delete 
Ignore my response below; I didn't see the CString title!
The first thing that comes to mind why it would not visually append would be that line is not null terminated.
Also I think the debug watch window only displays string values up to a certain length, then its truncated. I know that this was so for VS6, not sure for VS.7
That is because
text += " "cannot be used on string variables.
I am assuming that text is a character buffer. If this is the case try:
_tcscat(text,_T(" "));// you could also use strcat() for non-unicode progs.
V. wrote: fscanf(readfile, "%s", line);
while(line.Find("\n") < 0);
If line is a CString object, it cannot be used as the third parameter to fscanf().
Assuming you are wanting to read lines from the file, there are at least two methods that make more sense. The first is to use "%[^\n]" instead of "%s". This will read everything up to the '\n' character. The second is to create a CStdioFile object and use its ReadString() method.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
Last Visit: 23-Oct-20 14:50 Last Update: 23-Oct-20 14:50