Winsock try catch exceptions

O

Oren

Hi,

I use the Winsock ActiveX in VS C++.
the problem is that I am unable to catch all the exceptions.
for instance if I have a server who listens at port 1111 and I try to
connect to the wrong port or if the server is offline I get error
messagebox "connection is forcefully rejected". it seems that I can't
catch that message somehow.

here is the code I use:

TRY
{
WinSockControl.SetProtocol(0) ; // TCP/IP
WinSockControl.Connect(COleVariant("127.0.0.1"),
COleVariant(long(1321))) ;
}
CATCH(CException, e)
{
MSGDialog("ddddddddddddd");
e->Delete();
}
END_CATCH

Does anyone know how to catch everything?
 
S

Sharad Kala

Oren said:
Hi, [snip]
here is the code I use:

TRY
{
WinSockControl.SetProtocol(0) ; // TCP/IP
WinSockControl.Connect(COleVariant("127.0.0.1"),
COleVariant(long(1321))) ;
}
CATCH(CException, e)
{
MSGDialog("ddddddddddddd");
e->Delete();
}
END_CATCH

Does anyone know how to catch everything?

There is a lot of non-standard stuff in your post. Anyways you can catch all
exceptions this way -
try {
// ...
}
catch(...)
{
// ...
}

Sharad
 
O

Oren

I know.
I tried everything including:

try
{
WinSockControl.SetProtocol(0) ; // TCP/IP
WinSockControl.Connect(COleVariant("127.0.0.1"), COleVariant(long(1321))) ;
}
catch(CException e)
{
MSGDialog("ddddddddddddd");
}

and it catches nothing.
Do you have any other suggestions?

Sharad Kala said:
Oren said:
Hi, [snip]
here is the code I use:

TRY
{
WinSockControl.SetProtocol(0) ; // TCP/IP
WinSockControl.Connect(COleVariant("127.0.0.1"),
COleVariant(long(1321))) ;
}
CATCH(CException, e)
{
MSGDialog("ddddddddddddd");
e->Delete();
}
END_CATCH

Does anyone know how to catch everything?

There is a lot of non-standard stuff in your post. Anyways you can catch all
exceptions this way -
try {
// ...
}
catch(...)
{
// ...
}

Sharad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top