|
Hi,
I am beginner in vc++, in my current project, I have one issue, I want some help from you.
I am creating, server socket & am listening for the clients. Once we have client, I am creating a seperate thread for that client.
Everything is done & working fine with this.
But, now the issue is, suppose Client socket is broken some how, & at that time if server sends the client the reply message, & if on client machine any firewall is installed, it treats the reply from the server under NMAP XMAS.scan.
to avoid this, before responding to the client, server should check wether client is alive or not, suggest me how can I do this?
|
|
|
|
|
You can't in the general case. Get a copy of TCP/IP illistrated by Richard Stevens to understand why (all volumns). (He died a few years ago, but the book is still worth reading, even if slightly dated)
The short of it is, the only way you know a client is alive is if you send data and it responds, and then you only know it was alive at the time it responded, which is always some time before you got the result. (normaly less than a second, but in the case of space craft can be hours!)
There are TCP/IP keep alives, but the time out is far too long to be useful for most purposes.
|
|
|
|
|
Hi !! All
i m facing Fixup linker error in my module. i have searched on internet and found that this problem arises when the memory model is not suitable for the application. to overcome this problem we must have the large memory model. i m using TC V3.0 and set the memory model to large , the program runs but when the function containing the bulitin function of c execute error occurs and programm exits from the dos shell. plz help me in fixing this error ? should i change some thing in my program?? i m using low level system programming in the code likes using the mouse interrupts and video interrupts? plz suggest some solution ASAP.
Best Regards
Thanks
Naina Khawaja
|
|
|
|
|
I considered replying with "This is the VC++ forum, not the Turbo C forum" but that would be so cliché. The only reason I mention it is that you may not get any help at all unless there happens to be a Turbo C user in the house. For me, it's been over 11 years since I've used that compiler.
I do not know an exact answer to your problem but with 16-bit code, being aware of the program's memory model was always very important. Crossing over into another program's address space was always a possibility and oh-so-easy to do with the segment:offset addressing scheme.
nainakhawaja wrote:
...the program runs but when the function containing the bulitin function of c execute error occurs...
How about showing us a code snippet and the error message? There are no guarantees but at least that would be a start.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Should I even bother using DrawDragRect or just write my own by using SetROP2?
DrawDragRect wouldn't draw off the window size so when I scroll up/down it won't follow along.
Someone mentioned in earlier post about using translate function for DragDractRect but I can't seem to find the function. With translation would it be possible drag a rectangle while scrolling down?
|
|
|
|
|
Anonymous wrote:
Someone mentioned in earlier post about using translate function for DragDractRect but I can't seem to find the function.
It's a member of the CDC class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have look through but I can't find the function that does the translation
|
|
|
|
|
Hmm! I have never used DrawDragRect(), but your question implies that you have a scrolling problem and not a drawing problem. This sounds like you want the window to scroll, much like the window scrolls when you are trying to select more text (w/mouse) than you can actualy see (automatic scrolling). You have to issue the scroll command your self when the edge of the rectangle reaches the edge of the window you want it to scroll. The best way to do this, that I have used, is to start a timer and check the edge position in the timer function and have it issue the scroll commands (based on the edge position). The reason you would use a timer is because, if you do not, it would scroll way to fast.
You might look for articles on simple text editors to see how they are handling the scrolling when a user is dragging a mouse.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I've already found quite some "niceties" regarding VC6 and function templates (template parameter must occur as argument, and template over type rather than typename isn't resolved correctly).
I found new one, that boils down to:
<br />
template <typename CHAR, typename STRLEN> void Foo(CHAR const * p, STRLEN lenFunc, size_t charsize)<br />
{ ... };<br />
<br />
Foo("Hello", strlen, 1);<br />
Foo(L"Hello", wcslen, sizeof(wchar_t);<br />
I haven't reproduced this in minimum code yet, but it's pretty obvious that the compiler (sometimes) uses just the wchar_t overload for both branches.
Q:
- is this valid code under the piercing eyes of the C++ standard?
- Is this a known problem for VC6?
- Is something known about VC7 / other compilers?
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Are you sure that the problem is not caused by the fact that Windows headers define CHAR according if Unicode or MBCS is set ?
Try changing the typename in the template to something that is not so "reserved" as CHAR is. Like 'TYPE_CHAR' and 'TYPE_STRLEN', for example. If the compiler still produces wchar_t overloads, then it might be a bug.
As for the questions.
- Like stated, overloading the CHAR typedef can be a bad mistake. Most compilers have in-built definitions for CHAR. Many of them resolve to 8-bit integer values, but some specific compilers (such as mobile device/mobile platform ones) might produce a different result. In eyes of the C++ standard, the code is correct, though, as 'CHAR' is not a base type, but 'char' is.
- Unknown. You could try posting this as a bug suggestion to Microsoft and see what they reply. Most possibly the reply is a suggestion to move into a newer programming environment.
- Unknown. Visual Studio compilers are aimed at producing Windows and Windows Embedded code. Because ANSI/ISO Standard doesn't support stuff like multithreading, many of these compilers are not entirely standard compliant. Make no mistake, this is due to the lacking standard, not due to Microsoft's ineptness in following the standard.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
OK, I'll try renaming them (although CHAR works fine for other templates).
I'll see if I can reproduce that in VC6 in an minimum environment, and if if so, try VC7.
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hi everybody,
I've got a strange behavior with my code.
I have a dialog-based program, which opens another dialog (modal) when the user click on the right menu item.
There, OnInitDialog() is called before the new dialog is displayed, and it it there where I initialize my dialog depending on how the dialog was created.
I do a set of LoadString() to display the texts of the dialog in the correct language. but after loading the strings, SetWindowText() crashes.
here is the code :
Call of the new dialog :
<font color=#0000FF>void</font> CFactEditorDlg::OnFileOpen() {
COpenFilesDlg dlg(m_strDBFile, m_strDestFile);
<font color=#0000FF>if</font> (dlg.DoModal() == IDOK) {
<font color=#008000>
}
}
New dialog's initialisation :
BOOL COpenFilesDlg::OnInitDialog() {
CDialog::OnInitDialog();
<font color=#008000>//...</font>
CString strWindowText;
strWindowText.LoadString(IDS_OFD_FACT_RECSTAT); m_psrFact->SetWindowText(strWindowText);
strWindowText.LoadString(IDS_OFD_DB_RECSTAT); m_psrDataBase->SetWindowText(strWindowText);
strWindowText.LoadString(IDS_OFD_PROMPT); m_psFactPrompt->SetWindowText(strWindowText);
m_psDBPrompt->SetWindowText(strWindowText);
<font color=#FF0000>-></font> strWindowText.LoadString(IDS_OFD_PREVIEW_BTN); m_pbPreviewFact->SetWindowText(strWindowText);
<font color=#008000>//...</font>
}
The real place having problem :
<font color=#0000FF>void</font> CWnd::SetWindowText(LPCTSTR lpszString) {
<font color=#FF0000>-></font> ASSERT(::IsWindow(m_hWnd));
<font color=#0000FF>if</font> (m_pCtrlSite == NULL)
::SetWindowText(m_hWnd, lpszString);
<font color=#0000FF>else</font>
m_pCtrlSite->SetWindowText(lpszString);
}
what does it mean ???
few day ago, this code was working well, and today, when i was updating another class of the program (which have no relation of any order with this one), it stops me there now...
can anyone help of any kind please ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Is m_pbPreviewFact mapped to a valid control? In other words, you've probably got a DoDataExchange() method that looks similar to:
void COpenFilesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, SOME_ID_HERE, m_pbPreviewFact);
} Look to make sure that SOME_ID_HERE is in the project's resource.h file with a unique number, and that it is also in the dialog's template in the project's .rc file.
toxcct wrote:
few day ago, this code was working well, and today, when i was updating another class of the program (which have no relation of any order with this one), it stops me there now...
What happens if you remove this class? Does the SetWindowText() call start working again?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
yes it does.
i put comments in the code sample, but before i do this into OnInitDialog() , I do :
pbPreviewFact = (CButton*)GetDlgItem(IDC_PREVIEW_BTN); i don't understand... the assert failure is like pbPreviewFact is not a window, but it actually is... !
the worst is that i didn't even modify this class !!!
I was only working on another new dialog, with no relationship with this one...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i have another strange fact :
if i move the line (in my code) that is giving me an error, i still have an error at the same line !!!, that means on another code line ! any idea ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Comment out each of the SetWindowText() statements and recompile. Does the problem go away? If so, remove the comment from each statement individually and see which causes the problem to start.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Also try "rebuild all." One of my pet peeves with VC6 is that it will not allow one to make Resource.h a dependency. That thoroughly annoys me. I can understand the rationale to not want it to be but to prohibit it from being one is stupid I think.
|
|
|
|
|
|
Rick York wrote:
One of my pet peeves with VC6 is that it will not allow one to make Resource.h a dependency.
In all of my projects, resource.h is indeed in the dependency list. What am I missing here?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Does anyone know of a good piece of code for formating phone numbers. By good, I mean formating based on country code (at the very least). Most of the hits I am seeing, on the WWW, seem to think it is pretty neat to be able to format a US phone number, but any programmer can do that (if someone cann't, there not a programmer).
Thanks for any help!
John R. Shaw
"If I was at home, I would not be Anonymous."
|
|
|
|
|
See the discussion here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David, thats about what I thought!
According to every thing I have now read even Microsoft cann't do it, except for certain countries with fixed formats (and problems may occur even for those). There is no garantee that any format will not change in the future; thereby breaking code depending on it.
John R. Shaw
"If I was at home, I would not be Anonymous."
|
|
|
|
|
Hi,
I'm havin a silly problem with a scroll bar. It works but it never scrolls all the way to the maximum range value.
For example here's the code:
<br />
SCROLLINFO ScrollInfo;<br />
ScrollInfo.cbSize = sizeof(ScrollInfo); <br />
ScrollInfo.fMask = SIF_ALL; <br />
ScrollInfo.nMin = 0; <br />
ScrollInfo.nMax = 125<br />
ScrollInfo.nPage = ScrollInfo.nMax / 10;<br />
ScrollInfo.nPos = 0;<br />
ScrollInfo.nTrackPos = 0; <br />
m_ImageHorizontalScroll.SetScrollInfo(&ScrollInfo); <br />
int result = m_ImageHorizontalScroll.SetScrollPos(10);
result = m_ImageHorizontalScroll.SetScrollPos(123);
result = m_ImageHorizontalScroll.GetScrollPos();
So I have to set the nMax to my value + a fudge number? What should that number be?
Thanks.
|
|
|
|
|
I have this code to change screen resolution, and it works for win98/2000
but it does not work for WinXP knowing that i log in as Administrator.
<br />
DEVMODE dm;<br />
dm.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT;<br />
dm.dmPelsHeight=600;<br />
dm.dmPelsWidth=800;<br />
ChangeDisplaySettings(&dm,0);
can anybody tell me whats wrong with this code, or another way that may work?
thanx all
Mohammad
A candle looses nothing by lighting another candle
|
|
|
|
|
Mohammad A Gdeisat wrote:
but it does not work...
What does ChangeDisplaySettings() return?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|