|
It's just bytes... use one of the many IPC types[^].
Sockets are likely your most commonly used IPC nowadays for a number of reasons, but there's always other options that have different benefits (and drawbacks of course). For example, simply having a shared file would be very simple since you just have to write the file to a shared location and then have a way of notifying the other application of the new file to process (notice can be done via Windows message or other such messaging mechanism, or simply have one application launch the other and load the proper file via command line arguments).
You have a lot of options, you have to decide what's important then implement accordingly. Happy coding!
|
|
|
|
|
I need to create one edit view which could be able to add different color txt automatially(actually by another thread). act like a monitor to monitor the message from serialport or tcp;
The message displayed shall be able have different color to make it has different meanings;(if different font is support is better)
Also when user scrolls up, it could stay at that scroll position, it did not scroll down automatically when new message arrived. User could select and copy the txt;
When user scroll down to the last line, it could scroll down automatically to the last line when background message is arrived; when scrolling, it did not flash(twinkle);
I have tried EditView & Richedit, all failed, the new txt added is by ReplaceSel, which will make the content auto scroll down to the last line, and user could not do Selection and copy when new txt added;
I have found the Visual Studio Trace window, it could add message automatially and user could easily select txt even when new txt added.
I am not sure how to realize it, this thing has bothered me a lot time, please someone could help me about this. Very appricate of your help;
modified 10-Jul-14 3:10am.
|
|
|
|
|
You could try subclassing the EditView so you can have greater control over the movement of text and the actual display. Alternatively you may need to create your own View class which will be specific to your requirements.
|
|
|
|
|
|
Hi,there.
I had a problem that can't solve it and I don't know why.
The problem is that when I sendto one data to one server,then i picked the data through Network Monitor.There is more data than I send.And the source mac is more other than my own pc's mac.
The problem I encountered first time and I don't know why it happened.
Look forward your help.Thank you.
|
|
|
|
|
You need to provide more detail if you want assistance on this.
|
|
|
|
|
|
How to apply the sobel operator to each image and display the edge images
|
|
|
|
|
Sweety08 wrote: How to apply the sobel operator to each image... Just like you would any other filter. Do you have the filter's source code or library?
Sweety08 wrote: ...and display the edge images Are the images on disk or in memory? Are you able to display them as is (i.e., no filter applied)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
for every pixel, calculate:
Gx =
-1 * p(x-1,y-1) + 1 * p(x+1,y-1) +
-2 * p(x-1,y) + 2 * p(x+1,y) +
-1 * p(x-1,y+1) + 1 * p(x+1,y+1)
Gy =
p(x-1,y-1) + 2 * p(x,y-1) + p(x+1,y-1) -
p(x-1,y+1) - 2 * p(x,y+1) - p(x+1,y+1) +
pOut(x,y) = sqrt(Gx * Gx + Gy * Gy)
(this is from Wiki)
|
|
|
|
|
I need to create an application (PlantModel Application) that needs to run at the background which is invoked by a MFC application which passes command line parameter to the application at the time of invoking.
This model application needs to transfer data across LAN network using TCP sockets and hence needs MFC support. At the same time this model application don't need GUI since it runs at the background only.
Please suggest, What is the best suited application type that can chosen during the creation in Visual studio 2008?
|
|
|
|
|
A simple console application may do it, or probably better, a Windows service.
manoharbalu wrote: transfer data across LAN network using TCP sockets and hence needs MFC support. TCP/IP has no requirement for MFC support.
|
|
|
|
|
My question is: How long must my WSABUF buffers remain valid after calling WSASend while using the WSAEventSelect model?
Background:
Quote: An FD_WRITE network event is recorded when a socket is first connected with a call to the connect, ConnectEx, WSAConnect, WSAConnectByList, or WSAConnectByName function or when a socket is accepted with accept, AcceptEx, or WSAAccept function and then after a send fails with WSAEWOULDBLOCK and buffer space becomes available.
So this means that I can call WSASend successfully until it returns WSAEWOULDBLOCK . But how do I know determinitively when it's OK to delete the buffers that I used in the calls to WSASend ?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
MSDN: The FD_WRITE event is handled slightly differently. An FD_WRITE message is posted when a socket is first connected with connect or WSAConnect (after FD_CONNECT, if also registered) or accepted with accept or WSAAccept, and then after a send operation fails with WSAEWOULDBLOCK and buffer space becomes available. Therefore, an application can assume that sends are possible starting from the first FD_WRITE message and lasting until a send returns WSAEWOULDBLOCK. After such a failure the application will be notified that sends are again possible with an FD_WRITE message.
From this (the last sentence specifically), I'm guessing that you're good to go the upon receipt of the first FD_WRITE after receiving WSAEWOULDBLOCK.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
That's what I thought at first, too. But upon further examination, one learns that if you don't send enough data to trigger a WSAEWOULDBLOCK response, then you never receive another FD_WRITE notification! In other words, the FD_WRITE event is recorded upon connect, and then only if you receive a WSAEWOULDBLOCK.
That's why I think this is so vague.
Thanks for your response.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Something this basic should really be documented, lord knows I couldn't find anything (which is not to say that it doesn't exist) that decribes this. I did find some wording on this[^] non-MSDN page, which talks about what happens to your buffer in reponse to a Send() call. No, it's not from the horses mouth, but it does make sense, at least to me.
Quote: When an application makes a send call, if there is sufficient buffer space, the data is copied into the socket's send buffers, the call completes immediately with success, and the completion is posted. On the other hand, if the socket's send buffer is full, then the application's send buffer is locked and the send call fails with WSA_IO_PENDING. After the data in the send buffer is processed (for example, handed down to TCP for processing), then Winsock will process the locked buffer directly. That is, the data is handed directly to TCP from the application's buffer and the socket's send buffer is completely bypassed. Hope it helps.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Thank you, that does help.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
The array of WSABUF[] structures pointed to by the lpBuffers parameter is transient data. You can even use build stack-based WSABUF[] arrays. If WSASend() returns successfully then the underlying transport has made a copy of your buffer.
Best Wishes,
-David Delaune
|
|
|
|
|
I would hope that's the case, but what about what it says in the documentation for the LPWSABUF parameter in WSASend:
Quote: For a Winsock application, once the WSASend function is called, the system owns these buffers and the application may not access them. This array must remain valid for the duration of the send operation.
See? It says they must remain valid throughout the send "operation." Not just the function call, but the entire send operation which may take a long time depending upon network conditions.
Is that how you interpret this?
Thanks for your expertise.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
For a Winsock application, once the WSASend function is called, the system owns these buffers and the application may not access them. This array must remain valid for the duration of the send operation.
What this is saying is that your buffer must remain valid for the duration of the the WSASend() call. Once the function has returned successfully you may delete the buffers.
Best Wishes,
-David Delaune
P.S.
You have mail.
|
|
|
|
|
Thank you, thank you!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
This is a tough one, I want to overload the arithmetic operators in a pur virtual abstract class.
The pur abstract class defines the basic 'Interface' from there I have a base parent class that will be the default implementation and several parallel child classes.
e.g.
virtual IClass operator+(IClass& RHS) = 0;
Then I can implement it in BaseClass.
Problem: Can not instantiate abstract class.
changing it to
virtual IClass& operator+(IClass& RHS) = 0; means that the statement is valid BUT it can't work (or can it?) this returns a reference to IClass which isn't what we want in addition, we want to return a value not a reference.
So how can I do this whithou getting in to memory leaks and such. For addition we want to be able to do result = a + b + c + d, etc.
This is pure old (not C++11) C++ I'm working in today.
CJ
|
|
|
|
|
So you have the following
class Child1 : IClass
class Child2 : IClass
What do you think the following is going to do?
Child1 op1 = ...
Child2 op2 = ...
Child1 result1 = op1 + op2;
Child1 result2 = op2 + op1;
|
|
|
|
|
One way to do it is by adding (pure) virtual accessors that read the elements that you need for the addition, and (pure) virtual factory methods that you can use to create an object of the correct type. The following might work:
class vecbase {
public:
virtual int size() const = 0;
virtual int& operator[](int i) = 0;
virtual int operator[](int i) const = 0;
virtual vecbase create(int sz, int* values) = 0;
friend vecbase operator+(const vecbase& a, const vecbase& b) {
assert(a.size() == b.size());
int* values = new int[a.size()];
for (int i = 0; i < a.size(); ++i) {
values[i] = a[i] + b[i];
}
result = create(a.size(), values);
}
};
Note that I declared the operator as a friend function, rather than a member function. I prefer that approach for binary operators in case I need operators for mixed argument types.
The functions in the derived classes should then change the result types of the overriden functions to the appropriate type:
class vec2 : public vecbase {
private:
int val[2]
public:
vec2(int* values) {
assert(values != nullptr);
val[0] = values[0];
val[1] = values[1];
}
int size() const { return 2; }
int& operator[](int i) { return val[i]; }
int operator[](int i) const { return val[i]; }
vec2 create(int sz, int* values) {
assert(sz==2);
return vec2(values);
}
};
I haven't tested this or even compiled, but this should be good enough to get the idea.
P.S.: just realized that I forgot to release the values array - that one will be a bit tricky, maybe you need additional pure virtual helpers to create and release a sufficiently large initialization array...
P.P.S.: I just realized this could be done much easier - all you need is a pure virtual function that performs the addition, and creates the resulting object as well:
class vecbase {
...
virtual vecbase add(const vecbase&, const vecbase&) = 0;
friend vecbase operator+(const vecbase& a, const vecbase& b) {
return add(a, b);
}
};
class vec2 : public vecbase {
...
public:
vec2 add(const vecbase&, const vecbase&) { ... }
};
Of course, that defeats the purpose of implementing the operator in the base class - but then you can't really do that without virtual helper functions anyway.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
modified 8-Jul-14 4:17am.
|
|
|
|
|
Hi, in one project, there are 2 dialog windows,each dialog take the whole screen area, that is. 800 X 600.
I put 2 Static text control in dialog window 1, when I switched back from dialog window 2, I found blinks in static text box, it display corresponding part picture of dialog window 2, then swap to background of dialog window 1.
I think this is because static text is a child window in dialog window1. so, it's repainting action is after the repainting of dialog window 1, the parent
window.
But I don't know how to synchronize the repainting, or let static text be repainted before the parent window.
Can somebody help me to solve it?
Thanks in advance
|
|
|
|
|