|
i guess server socket must be on NT Server platform and client socket can be on any platform (95/98/200/station etc.).
is the 'guess' right?
if i install more software, can i run them on different plateform?
thanks.
includeh10
|
|
|
|
|
No no, a server socket is simply any socket on any platform which is listening for a connection.
a client socket can be any socket which is connected to a server socket.
This has nothing to do with the fact that the actual computer is a server or client. a server machine can connect to your personal computer, but its socket is still called the 'client' socket.
There may be limits on the number of connections an OS can accept at once, etc., but still, that doesnt stop you from using even windows 3.1 sockets as 'server' sockets.
|
|
|
|
|
thank u for the message.
so, for example, CSocket can work as both 'accept' - just call it server - and 'connect to the accept' - just call it client.
both can be on any win/nt platform.
in java, there are 2 different sockets: ServerSocket and Socket, according to ur opinion, there is no such symmetric things in c++ for win/nt?
is my understanding right?
regards
includeh10
|
|
|
|
|
There are Java-style socket libraries for C++ that implement separate Socket/ServerSocket classes. Or if my recollection is false, you can implement one yourself;)
|
|
|
|
|
I write a data server, which just simply open an ADO recordset in the server, and sends data to the client. The client will also maintain a RowList. However, I'm when a user Added a new record locally, I don't know where I should put the record in, as it has to be in the same position as the server's one, otherwise the records are not synchronized with MoveNext, MovePrevious operations.
say, in the 3 record, the user AddNew and save. I should put the newly added record in the 4th position, and in the Server's recordset, i do the same in the 3rd record, and the record will go into 4th position in the server's recordset too ???
|
|
|
|
|
i try to run a program from c++, but how to get info from io stream?
i.e. run javac.exe, it displays a lots info in command window, i want to get the info to my c++ app at run time.
if use java Runtime class, i can do it, but i want to use c++ now.
please help!
includeh10
|
|
|
|
|
|
If that's too "heavy", and onlystdout is needed, a plain call to _popen will do. Example
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
char psBuffer[128];
FILE *chkdsk;
if( (chkdsk = _popen( "dir *.c /on /p", "rt" )) == NULL )
exit( 1 );
while( !feof( chkdsk ) )
{
if( fgets( psBuffer, 128, chkdsk ) != NULL )
printf( psBuffer );
}
printf( "\nProcess returned %d\n", _pclose( chkdsk ) );
}
|
|
|
|
|
good idea, thanks. i will try more once i have time.
cheers.
includeh10
|
|
|
|
|
What is the wrong ?
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
class MyMath
{
public:
friend int Sum(int v1, int v2);
};
int Sum(int v1, int v2)
{
return v1 + v2;
}
void main()
{
MyMath obj;
cout << "Result: " << obj.Sum(1, 3);
_getch();
}
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Your MyMath class's Sum function is public to other classes so there is not need to declare it as friend. And you can declare the method as friend if you are writing a class template(generating new classes depending upon what type of parameters you pass to the function). In your code I do not see a reason for declaring it as a friend or also it not possible to declare it as a friend.
Einstein's Assistant
|
|
|
|
|
Hi.
I have uploaded my whole application in my temp. yahoo account. I could not locate the source of memory leak. Please help me to pin point source of serious memory leak. I have uploaded a zip file in the yahoo briefcase.
Yahoo details
userid : moswal0071
password : cooldude
Thanx in advance.
Einstein's Assistant
|
|
|
|
|
Can anyone provide an example of a circular queue in C? I've never used one before and researching on the net has shown a whole host of approaches of which I think have alot of overhead.
1) I don't want to and can't use STL since this is a C program.
2) All examples I've seen use data structures like a linked list with "next" pointers and one of the attributes is the data itself.
3) They also have all of the functions which add, delete, check for empty, etc. but I don't want to spend the time doing this for the reason specified below. I don't want to call functions but do this on the fly as I add or remove data from the queue.
4) I'm reading from a serial port at 115k baud in a read thread and don't have any time to format the data so I would like to do a memcopy to an array or circular buffer so it must be contiguous but then there is the wraparound problem I'm aware of. Worst case, a for loop. I will process or format the data into it's proper format in another thread which will access this circular queue as the read thread is putting data into it.
5) Shouldn't it be as simple as a char array of certain size with two char pointers; one to head and one to tail? I know how to see if the queue is empty but how do I detected overrun? If detecting overrun is simply is head > tail then what about when I wrap around to the beginning of the buffer?
Any code examples and suggestions would be appreciated.
John
|
|
|
|
|
I imagine most modern programs use FIFO linked lists for the reason you state -- data overruns. With a circular queue you have one of two choices to make: either overwrite existing data or discard new data until some function removes data from the queue. The programs I wrote discarded the data because overwriting existing data usually renders the contents of the entire queue useless. You need to make your circular queue large enough to handle most situations which largly depends upon how frequently data is removed from the queue. You need four pointers, not just two. Head & tail for incoming data and head & tail for outgoing data. Maintaining these four pointers is actually as much if not more overhead then a simple linked list with just a next pointer.
|
|
|
|
|
The basic circular buffer is as you describe in point 5. Maintain two numbers, Read and Write which correspond to the read and write locations within the buffer. You can then use array notation rather than pointers which makes the arithmetic more intuitive.
Let's use recording audio as an example. The soundcard driver gives you regular buffers of data. Simply copy this into your circular buffer at the write position. To make wrapping arithmetic easy (and also ensuring only one memcpy is needed per iteration), make the size of your circular buffer a multiple of the size of the buffers the soundcard provides. For example, if the soundcard gives you 1024 sample buffers, make the circular buffer 16384 samples long.
Decide what rate you want to read data from the circular buffer e.g. in 8192 blocks. Then when you write to the circular buffer firstly update the write location and then check to see if the difference between read and write is >= 8192 (easy way to do this is to add the size of the circular buffer to each location and then take the difference). If it is, then signal your read thread to read the fresh data (and update your read pointer). This is easier than getting your read thread to continuosly poll thus leaving it more time to finish the formatting. Everytime you change the read or write values, make sure you use modulo arithmetic:
Write+=1024;
Write%=16384;
Read+=8192;
Read%=16384;
Hopefully, you shouldn't have problems with overrun since you're forcing a read when data is available. Experiment with buffer sizes to find the most efficient way. With audio, it's good to have small buffers since you get low latency, in your case it may not be necessary; bigger buffers put less strain on the CPU.
Hope this is useful.
|
|
|
|
|
Thanks, guys for the suggestions. I think I have it done now. I still need to test it with a max load of data. I kept my buffers kind of small because of the application. I wanted to timestamp each 8, 14, or 32 byte message with a unique timestamp in msecs. However, legacy software only supports resolution to 10ths of a second.
Consequently, I used a small receive buffer of 128 bytes and a circular buffer of 1024 bytes. Though, I won't be able to maintain the millisecond accuracy, it should be fine for 10ths of a second.
I wrote it so that the read thread calls SetEvent() in which the process thread waits infinitely for. So, it doesn't poll and only gets used if there is data to process.
I found a pretty good example online of a C++ class that implemented a circular queue and I converted it to C. The thing I like about this one is that the front or head is always one position less then where the data actually begins making it easier to detect when the queue is full. Of course, that means one element in the queue is not used or 1023 of 1024 elements are used.
And as one of you wrote, I decided to discard any data if the processing thread couldn't keep up.
I'm still experimenting around but as its set up now the read thread is at a priority of 15 while the process thread is set to 15 when WaitingForMultipleObjects() but 17 when it gets control. Do you guys have any advice on this or does that sound normal?
Thanks again.
|
|
|
|
|
Hi. I am using the windows XP-style controls (commctl32 version 6). In this, the tab control's "client area" is colored differently from the background, and is not a single color. So, when I put a control on top, such as the label (static) control, or a radio button, the dialog background fills the area of the control, making it look rectangular and ugly. Is there any way to make the text of my controls transparent rather than opaque, so that I can avoid this problem?
Thank you.
- Andy Oxfeld (andy@serialgaming.com)
|
|
|
|
|
I need to create "Help Topics" for each of my WinCE application programs that run on PocketPC 2002 using eVC++ 3.0 compiler. On desktop programs use WinHelp.exe, but that program does not exist on the PPC device. Does anyone know how to do this?
|
|
|
|
|
|
Can someone show me where I can find an example to write a program that will have multi language gui. For example user will select the language that he wants and gui will be in that language
Thank you
Orcun Colak
|
|
|
|
|
I suppose you'd use multiple resource-bearing files,
one for each language, and then use AfxSetResourceHandle
to specify which to use. Then make sure to code your
project with no inlined strings-- everything from the
resources.
Here's some google results:
TN057, Q147149, over at Microsoft
http://www.codeguru.com/misc/MultiLang.shtml
http://www.eanet.cz/~lvanek/develop/windows/international/international.htm
I love search engines.
|
|
|
|
|
I'm having a problem with MessageBox(). I am creating a thread to interact with a device driver and if the driver is not loaded/started, I'm trying to display a message to the user. All that happens is that the message box pops up for a second.
The return is 1 (IDOK) and GetLastError is 0 (I called SetLastError(0) before MessageBox).
I'm calling:
::MessageBox (NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION);
Thanks for the help,
David
|
|
|
|
|
|
Anyone knows how to deal with ghost windows in XP? How to get rid of the ghost windows in windows XP system with Platform SDK? Thanks.
Windows XP: If a top-level window stops responding to messages for more than several seconds, the system considers the window to be hung and replaces it with a ghost window that has the same Z order, location, size, and visual attributes. This allows the user to move it, resize it, or even close the application. However, these are the only actions available because the application is actually hung. When in the debugger mode, the system does not generate a ghost window.
reference from MSDN.
mIchAel Liu
|
|
|
|
|
Until you learn to write a subject line that is
1 - not an attempt at giving me/us an ORDER and
2 - learn to not fill it with completely annoying characters;
I have but one advice for you: Have a nice day, go play on the highway.
|
|
|
|