|
It is not working. I've probably tried all the combinations. Now, since it is an extension Dll, I am calling AfxInitExtensionModule and AfxTermExtensionModule from DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH respectively. But still the problem persists. ie the dll does not respond when I try to create the socket.
Plz check it out, if you could.
Thanks
|
|
|
|
|
Definitely no inheritance. The objects have different roles: use inheritance sparingly, and only when a derived class is is the same "thing" as the superclass, with a couple of extra bells and whistles
Particularly with the same "thing" idea...when using inheritence???
FYI...the guy is refering to a set of classes like...
CxDatabase<br />
CxValidator<br />
CxAuthorize
|
|
|
|
|
When confused wether or not to use inheritance, i go by "is a" or "has a" rule explained in Deitel, "C++ - How to program".
In the above case, the same "thing" refers to "is a" case.
Well, I am absolutely comfortable with the above idea.
|
|
|
|
|
Yes, I agree. Inheritance is used too much, and containment is not used enough ( has-a, instead of is-a ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
I totally agree. Inheritance is a good thing, but certainly too much in a lot of cases. Some disadvantages come with inheritance. One thing are extra physical dependancies. If you use too much inheritance, your compilation process will take considerably more time.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Inheritence is used much more then containment
this is due to many reasons supporting advantages of inheritence
"Everthing has its own specail importance " Quote by some great person
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Yes, this is true. But it's also often used without thought.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a class that is derived from CDialog that declares the following:
<br />
BEGIN_EVENTSINK_MAP(CColorPage, CPage)<br />
<br />
ON_EVENT_RANGE(CColorPage, IDC_COLOR_BUTTON1, IDC_COLOR_BUTTON10, -607 , OnMouseUpButton, VTS_I4 VTS_I2 VTS_I2 VTS_I4 VTS_I4)<br />
END_EVENTSINK_MAP()<br />
When I compile the code, I get the following error messages:
C:\TMLnkV32\ColorPage.cpp(92) : error C2509: '_GetBaseEventSinkMap' : member function not declared in 'CColorPage'
c:\tmlnkv32\colorpage.h(26) : see declaration of 'CColorPage'
C:\TMLnkV32\ColorPage.cpp(92) : error C2509: 'GetEventSinkMap' : member function not declared in 'CColorPage'
c:\tmlnkv32\colorpage.h(26) : see declaration of 'CColorPage'
C:\TMLnkV32\ColorPage.cpp(92) : warning C4273: 'protected: static struct AFX_EVENTSINKMAP const CCmdTarget::eventsinkMap' : inconsistent dll linkage. dllexport assumed.
C:\TMLnkV32\ColorPage.cpp(92) : error C2491: 'CColorPage::CTabPageSSL::CDialog::CWnd::CCmdTarget::eventsinkMap' : definition of dllimport static data member not allowed
C:\TMLnkV32\ColorPage.cpp(96) : error C2248: 'OnMouseUpButton' : cannot access protected member declared in class 'CColorPage'
c:\tmlnkv32\colorpage.h(66) : see declaration of 'OnMouseUpButton'
I am looking for suggestions as to what I am doing wrong.
Thanks in advance.
Eldon Zacek
|
|
|
|
|
Maybe this MSDN example helps:
struct A {
virtual int vfunc() = 0;
virtual int vfunc2() = 0;
};
struct B : private A {
using A::vfunc;
virtual int vfunc2();
};
int B::vfunc() { return 1; }
int B::vfunc2() { return 1; }
SkyWalker
-- modified at 3:48 Wednesday 19th October, 2005
|
|
|
|
|
Thanks for looking at this, I found the problem. I forgot to include DECLARE_EVENTSINK_MAP in the ".h" file.
Eldon Zacek
|
|
|
|
|
DrawText is too slow when string is long enough and without "\n" among the string charaters.any body knows another way instead DrawText?
thanks regards.
|
|
|
|
|
TextOut()
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
Great! But I have a problem with multiline text,I want to text it like a multiline edit control does. I don't know when should I break up the line and start a new line to text. in another word:
I need a method to cauculate one character's width, it isn't only limited in english characters. thanks,so much
life is like a box of chocolate,you never know what you r going to get.
-- modified at 1:42 Wednesday 19th October, 2005
|
|
|
|
|
I think you need GetTextExtent
Dr.pi
|
|
|
|
|
hi all, i am making an multithread client that connects to differents servers using differents threads.
in the main window the user select the numbers of connections that the program will start.
To make make this i created the threads inside a loop like this:
GetDlgItemText(IDC_SIMULTANEOS, n);
int a = _ttoi(n.GetBuffer(n.GetLength()));
for(LONG i=0; i<a; i++)="" {
="" m_servername.gettext(i,="" str);
...
....
="" pthread-="">ResumeThread();
}
The program creates succefully the number of connections to the server specified in a, for example it creates 2 threads.
Now, i need to do read operations on the different threads created.
I can see theat write and read operations works only on the last process(thread, connection) created.(sniffing packets i
realize that the data pushed are in the higher port number of the two established connections on my local machine to the
second server on the list).
How can i identify the different threads created in the loop and make write and read operations on them??
Thanx in advance.
|
|
|
|
|
|
U have created a message with wrong tag
insted of the code tag u selected the link tab
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi, i'm setting up a winsock connection with client and server code. The server code seems to work fine, and so does most of the the client code. However, I'm having difficulty connecting to the host. I've tried gethostbyname("www.something.com"); but I don't have a site or something where it's hosted. I figure that if there's some way to find the IP of the socket as the host creates it, the host person could tell the client person what the IP is and have them input it. I'm sure there's a better was, though, and i'm sure you guys know it. Here's the code, I've marked where the error is, but it is in the second half of the code inside the else{}, meaning that the user wants to be a client. You may also notice that this code is from an online tutorial; I had hand-written it, but there was some extremely hard-to-find error and I figured I'd use this instead of re-write. It works fine except for my incompetence. lol. Anyway, thanks in advance. Here's the code:
//--------------------------------start the winsock Connection---------------------------------
cout << "Initializing WinSock..."<<endl;
cout << "will you be joining a previously created server? [y/n] (no means you will create a new server) : ";
cin >> joining;
WORD sockVersion;
WSADATA wsaData;
int nret;
sockVersion = MAKEWORD(1, 1);
// Initialize Winsock as before
WSAStartup(sockVersion, &wsaData);
// Store information about the server
LPHOSTENT hostEntry;
// Create the socket
SOCKET theSocket;
// Wait for a client
SOCKET theClient;
SOCKET listeningSocket;
// Use a SOCKADDR_IN struct to fill in address information
SOCKADDR_IN serverInfo;
cout << "All variables initialized..."<<endl;
if(joining != 'y')
{
listeningSocket = socket(AF_INET, // Go over TCP/IP
SOCK_STREAM, // This is a stream-oriented socket
IPPROTO_TCP); // Use TCP rather than UDP
if (listeningSocket == INVALID_SOCKET) {
nret = WSAGetLastError(); // Get a more detailed error
ReportError(nret, "socket()"); // Report the error with our custom function
WSACleanup(); // Shutdown Winsock
return NETWORK_ERROR; // Return an error value
}
cout << "Set up connection..."<<endl;
serverInfo.sin_family = AF_INET;
serverInfo.sin_addr.s_addr = INADDR_ANY; // Since this socket is listening for connections,
// any local address will do
serverInfo.sin_port = htons(8888); // Convert integer 8888 to network-byte order
// and insert into the port field
cout << "Setup host info..."<<endl;
// Bind the socket to our local server address
nret = bind(listeningSocket, (LPSOCKADDR)&serverInfo, sizeof(struct sockaddr));
if (nret == SOCKET_ERROR) {
nret = WSAGetLastError();
ReportError(nret, "bind()");
WSACleanup();
return NETWORK_ERROR;
}
//print the IP of the socket that was created
cout << "Socket successfulyl bound..."<<endl;
// Make the socket listen
nret = listen(listeningSocket, 10); // Up to 10 connections may wait at any
// one time to be accept()'ed
if (nret == SOCKET_ERROR) {
nret = WSAGetLastError();
ReportError(nret, "listen()");
WSACleanup();
return NETWORK_ERROR;
}
cout << "Listening for connections..."<<endl;
theClient = accept(listeningSocket,
NULL, // Address of a sockaddr structure (see explanation below)
NULL); // Address of a variable containing size of sockaddr struct
cout << "Recieved connection... \nAccepting connection..."<<endl;
if (theClient == INVALID_SOCKET) {
nret = WSAGetLastError();
ReportError(nret, "accept()");
WSACleanup();
return NETWORK_ERROR;
}
cout << "All steps completed..."<<endl;
}
else
{
cout << "Getting host..."<<endl;
//------------ERROR---------------------------------------------------------------!!!!!!!!!!
//I don't know if there's some way I can use one of these or what
/*option 1:
LPHOSTENT hostEntry;
in_addr iaHost;
iaHost.s_addr = inet_addr("204.52.135.52");
hostEntry = gethostbyaddr((const char *)&iaHost, sizeof(struct in_addr), AF_INET);
*/
//option 2: hostEntry = gethostbyname("www..com");
//-------------END ERROR---------------------------------------------------------!!!!!!!!!!!
if (!hostEntry) {
nret = WSAGetLastError();
ReportError(nret, "gethostbyname()"); // Report the error as before
WSACleanup();
return NETWORK_ERROR;
}
cout << "Host successfully retrieved..."<<endl;
theSocket = socket(AF_INET, // Go over TCP/IP
SOCK_STREAM, // This is a stream-oriented socket
IPPROTO_TCP); // Use TCP rather than UDP
if (theSocket == INVALID_SOCKET) {
nret = WSAGetLastError();
ReportError(nret, "socket()");
WSACleanup();
return NETWORK_ERROR;
}
cout << "Socket successfully created..."<<endl;
serverInfo.sin_family = AF_INET;
// At this point, we've successfully retrieved vital information about the server,
// including its hostname, aliases, and IP addresses. Wait; how could a single
// computer have multiple addresses, and exactly what is the following line doing?
// See the explanation below.
serverInfo.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list);
serverInfo.sin_port = htons(80); // Change to network-byte order and
// insert into port field
cout << "Set host info..."<<endl;
// Connect to the server
nret = connect(theSocket,
(LPSOCKADDR)&serverInfo,
sizeof(struct sockaddr));
if (nret == SOCKET_ERROR) {
nret = WSAGetLastError();
ReportError(nret, "connect()");
WSACleanup();
return NETWORK_ERROR;
}
cout << "Connected..."<<endl;
}
send(theSocket, "hey", 4, 0);
char readin[4];
recv(theSocket, readin, 4, 0);
cout << readin;
//-----------------------------------------------------end WinSock code-----------------------------------------------
--------------------------------------------Signature-------------------------------------------------
-How are you gentlemen!! All your base are belong to us. You have no chance to survive make your time.
-What you say!!
|
|
|
|
|
hello
i have used directly the socket i want to use the
socket ActiveX available ("WinSock").
Do have any idea.
the main reason behind using an acitveX is that the
response from the client is not guranteed , so when
do listen(client); many times my application hangs-up
any solution do u know
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I want to write a program that supports mutilanguage. so I read strings
in a ini file. who can help me ?
Just relax
|
|
|
|
|
I ve got a socket listening and accepting on another socket, how would I copy 2nd socket to a 3rd socket, so I would be able to close the 2nd socket...
// create temp and permanent sockets
CSocket tSocket, pSocket;
// accept listening onto temp socket
m_pListenSocket->Accept(*tSocket);
tSocket->Init();
// copy temp to perm
pSocket->Attach(*tSocket); or pSocket=tSocket;
produces the same.
pSocket->Init();
pSocket will pass data now,
// close the temp socket
tSocket->Close();
now pSocket won't pass data.
any helps always appreciated.
shotgun
|
|
|
|
|
afaik u would have to send a message to the client telling it to disconnect from the current socket and reconnect at a socket u pass to it in the message ... that way u can hand off clients to arbitrary servers and sockets
this is usually how i write servers who accept the client connection and authenticate them before handing them over for the actual data transfer
hth
"there is no spoon" {biz stuff} {about me}
-- modified at 23:52 Tuesday 18th October, 2005
|
|
|
|
|
CSocket pSocket,tSocket;
//This will Attach the Socket handle
pSocket.Attach(tSocket.m_hSocket);
//Donot Do any other operation b/w these 2 Lines on the Socket
//This will detach the Socket Handle in the m_hSocket data member of tSocket and set to NULL
Socket handle=tSocket.Detach();
|
|
|
|
|
hello
i have used directly the socket i want to use the
socket ActiveX available ("WinSock").
Do have any idea.
the main reason behind using an acitveX is that the
response from the client is not guranteed , so when
do listen(client); many times my application hangs-up
any solution do u know
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi,
I had the following code to close my dialog application when ESC key is pressed. But WM_KEYDOWN is not invoking at all.
What am I missing here....
case WM_KEYDOWN:
{
switch (wParam)
{
case VK_ESCAPE:
ExitApp(hDialog);
break;
}
return TRUE;
}
|
|
|
|