Re: copy pointer CSocket class
I just found out that in Server appl.
I change all CSocket into CAsyncSocket
and in Client appl.
I change all CSocket into CAsyncSocket
when I invoked
if (dsocket.Connect(dsocket.ip,PORT_A))
{
connect->EnableWindow(FALSE);
disconnect->EnableWindow(TRUE);
}
else
{
MessageBox("Unable to Connect ");
}
It will go to if statement=FALSE although the message has been
received by Server.
How to fix this?
Meanwhile, if Client is CSocket, if statement=TRUE
Thank you.
Regards,
Rehmet
On Mar 17, 9:22 am, Rehmet <rgnurrah...@gmail.com> wrote:
Hi Guys,
First of all, I would like to thank AliR, Joe and David for the
replies.
I am sorry I didn't inform you the background of my problem,http://groups.google.com/group/microsoft.public.vc.mfc/browse_thread/...
It's about why my CPtrList does not send to all the listed users of
pointers that it holds.
Well, we have a concensus here, that I should change my CSocket to
CAsynSocket.
And also new idea pointed out by Joe is to use SocketList instead of
CPtrList.
OK. let me try. I would post my code whether it fails or succeeds.
Thank you guys.
Regards,
Rehmet
On Mar 15, 8:09 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
You can't copy objects like this. So the solution is to not allow assignment at all. You
should use pointers. If you are trying to pass the object across threads, it is even more
complex. Wny do you think that doing an assignment like this is a reasonable solution?
(You're asking how to do something without actually stating the problem it is supposed to
solve. This won't work, mostly because you cannot have two CAsyncSocket entries...oh yes,
I know you said CSocket, but NEVER use CSocket for anything! It doesn't work, andyou do
not want to use synchronous sockets for anything that is in the slightest way real,
including toy programs of your own)
First: convert to use CAsyncSocket. This is the only reasonable way to handle sockets.
Second: state why you want to copy an object
(The problem in doing an object copy is that the SOCKET handle is what couples the socket
to a particular object; this cannot work if the SOCKET handle is used in more than one
object, and if you circumvent the built-in ASSERT tests that discover this, then your code
WILL malfunction in fascinating and creative ways)
joe