|
This is a Winsock question.
I have a TCP server application that is listening for connections on port 9000. When the client application connects I do an accept(). If I look at the port number of the socket returned by accept I see a semi-random port number. My question is, can you specify what this port number will be? If I want my client port numbers to start at 9001 and go to a max of 9500, can I programatically do this? I have searched the Winsock API but I have not found an example.
Thanks
|
|
|
|
|
Hi, you can specify the port on the client side like this...
//set port to 5001, not set by user
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr(HostIPAddress);
clientService.sin_port = htons(5001);//<-set IP port here
I dont know if this helps you.
Good luck.
Jerry
|
|
|
|
|
If I can ask -- what's your motivation for controlling the client-side port?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hi all,
I need to have a CSplitterWnd class to be embedded in a CView class. (I know it is weird, but due to my constraints I have right now, this seems to be the only choice.) I wonder is it possible of doing this?
I try to create a CSplitterWnd with the parent MainFrame, create its own CCREATECONTEXT. It is fine up to this point. But, when I call subclassDlgItem () to make it become the child of my CFormView, the result is that the whole splitter Wnd disappear.
I wonder if anybody has done this before.
Thank you.
|
|
|
|
|
Jimmy Chu wrote:
I need to have a CSplitterWnd class to be embedded in a CView class. (I know it is weird, but due to my constraints I have right now, this seems to be the only choice.) I wonder is it possible of doing this?
You can't put it in the CFrameWnd -derived class?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Seems like you are not designing the code properly, Coz if you do it will work out fine... spliterwindows needs to go into CFrameWnd derived class.
Prakash,
India.
|
|
|
|
|
Jimmy Chu wrote:
I need to have a CSplitterWnd class to be embedded in a CView classAnd
And this doesn't work? CSplitterWnd only takes a CWnd* as parent. It does not need a CFrameWnd* .
Can you further explain your design and maybe post a (stripped down!) code fragment?
I am under the impression what you want is possible, and you are maybe doing a small mistake.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
We have a main project called "Alphabet". It contains three sub-projects called "A", "B", and "C".
We now have a new subproject we call "D".
The "Alphabet" project now contains a compiler definition in the project settings called "NEW_ALPHABET".
We want to compile the "Alphabet" project so that by including or omitting the "NEW_ALPHABET" definition, we can compile and link in either "B" or "D", but not both.
Can this be done, and if so, how?
------- sig starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
"You won't like me when I'm angry..." - Dr. Bruce Banner
Please review the Legal Disclaimer in my bio.
------- sig ends
|
|
|
|
|
Can't you use some preprocessor code in Alphabet's stdafx.h file?
Something like:
<br />
#ifdef NEW_ALPHABET<br />
<br />
#pragma comment(lib, "B.lib")<br />
<br />
#else<br />
<br />
#pragma comment(lib, "D.lib")<br />
<br />
#endif
You'll have to have the correct header files included, and have the directories where those headers and lib files live included in the project settings.
|
|
|
|
|
Yeah this can surely be done.
What you do you had a new project settings by Build->Configuration.
You simple need two sets of entries one that involves B and other that involves D for compilation and linking.
Do the appropriate changes in the project setting to link the proper libraries... And also set the appropriate dependancies.
this way you will ignore the build of the project that is needed and plus you will not have any confusion during each build on which lib file was linked.
Prakash,
India.
|
|
|
|
|
new to makefiles.
Heres my problem:
I used an xstring (custom) object in a class myClass, which has a functionality test fMyClass. In the makefile I did:
fMyClass.x: $(proj)/fMyClass.o myclass.o
$(CC) -o fMyClass.x fMyClass.o myclass.o
fMyClass.o: $(proj)/fMyClass.cpp
$(CC) -c $(incpath) $(proj)/fMyClass.cpp
myClass.o: $(proj)/myclass.h $(proj)/myclass.cpp $(cpp)/xstring.h $(cpp)/xstring.cpp
$(CC) -c $(incpath) $(proj)/myclass.cpp $(cpp)/xstring.cpp
and it gives me errors like:
Undefined first referenced
symbol in file
operator<<(ostream &, XString const &)myclass.o
XString::~XString(void) myclass.o
XString::XString(char const *) myclass.o
I do have xstring.h included in myclass.cpp.
What do I need to fix here? The fMyclass doesnt use xstring, but myclass does.
thanks,
ns
|
|
|
|
|
Hi ns,
Don't you need also to include an additional xstring.o entry and add it to fMyClass.x ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thats exactly it!! I had been trying different places to put in the xstring.o but it didnt occur to me to add it to the fMyClass.x line as well. Many many thanks!
ns
|
|
|
|
|
Can some one tell me, How do I pass Typdef name which is stored in string variable to be passed to as a functions parameter.
For eg: LOOKUP_CODE (which is a typedef for struct)
LOOKUP_CODE MYCODE[]=
{
{0, _T("1234")},
{1, _T{"3455")},
{NULL ,NULL}
}
I use to call my function, which takes the first parameter of LOOKUP_CODE
MyFunction(MYCODE,....) This works like charm.
Now I'm storing that name MYCODE into string variable strCode
LOOKUP_DEF Class = reinterpret_cast<lookup_def &="">(strCode);
and calling the function like this:
MyFunction(&Class,...) but it does not work correctly. Any input from any one is greatly appreciated.
|
|
|
|
|
I really cannot make sense of what you're trying to do. Maybe you could post some more code illustrating your problem?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How would I pass the name of typedef which is stored in string variable as a parameter to an function which accepts the typedef data type?
For Example:
Name of the typedef is CODE, so the function will be called like this MyFunction(CODE).
What I'm trying to do is store the typedef name in string variable StrCode then call MyFunction((Type cast) strCode).
Question is how do I type cast the string variable to typedef in this suitation, I tried using reinterpret_cast, but it did not work.
|
|
|
|
|
This is called run-time type information (RTTI) and C++ generally isn't designed for it. The main reason was IMHO that well-designed program can do without RTTI, and accomplish this features by polymorphism etc. But, especially when you read objects from stream, RTTI is necessary.
VC provides the typeid operator and type_info class, but this is a nonstandard C++ extension. And it can be used only for opposite direction (convert typename to string).
So you probably have to write your own class, which manages a mapping from strings to typenames. Various libraries uses various techniques for RTTI. MFC does it through a massive macro gymnastic; a month ago I made RTTI for a particular purpose via templatized class factories...
These techniques are quite complicated to describe it here, so I could send you some tips by email. I don't know about any standard technique, but I'm quite interested about it. If there's anybody, who knows more, let me please know, we can discuss
Robert-Antonio
"Friends come and leave, but teddybears stay in forever."
|
|
|
|
|
|
Thank you very much, that was of great help!
|
|
|
|
|
http://www.codeproject.com/managedcpp/adonetinmfc.asp?target=ado%2Enet%7Cmfc
I did the same way as the above article said. I want to use the CTreeCtrl instead of CListCtrl. but I got the following errors and don't really know why i got those errors
<br />
An unhandled exception of type 'System.TypeLoadException' occurred in proj1.exe<br />
<br />
Additional information: Could not load type _TREEITEM from assembly proj1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.<br />
please help me
|
|
|
|
|
I am using Visual C++ 6 on Windows XP Professional.
I am busy writing an Application Wizard. On two of the dialogs I have an edit control that must initially must be displayed as disabled. After the user makes a certain selection then the edit control is enabled.
I have tried using GetDlgItem() and a cast to CEdit followed by called ModifyStyle on the CEdit control with WS_DISABLED as the first parameter and NULL as the second. However when it comes time to enable the control, it doesn't appear to be enabled even though one can enter text into it.
Help!! Any ideas?
I am the handsome one in the crowd.
|
|
|
|
|
For CEdit, have a look at CEdit::SetReadOnly, and for the other controls, CWnd::EnableWindow.
To get the control, GetDlgItem should work.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
I have an MFC application that has several buttons on it that correlate to a counter being increment on a standard left click. I was wondering if there was a way to differentiate between a left click and right click. If so the left click would incremente the counter while the right click would decrement the counter. I know how to do this in C# but sadly not in MFC.
Thanks
There are 10 kinds of people in those world. Those who understand binary and those who don't.
|
|
|
|
|
WM_LBUTTONUP & WM_RBUTTONUP may help you someway.
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible
Prakash,
India.
|
|
|
|
|
Hi,
how to generate random. random number value lies between particular range. any one help to me. thanks in advance.
Have A Nice Day!
Murali.M
|
|
|
|