Click here to Skip to main content
15,914,642 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSelecting CListCtrl Column Pin
zohar9419-Oct-07 9:50
zohar9419-Oct-07 9:50 
AnswerRe: Selecting CListCtrl Column Pin
Hamid_RT19-Oct-07 19:54
Hamid_RT19-Oct-07 19:54 
QuestionStore an image file on printer memory Pin
ShilpaPotnis19-Oct-07 9:39
ShilpaPotnis19-Oct-07 9:39 
Questionunhandled exception Pin
staticplus19-Oct-07 7:54
staticplus19-Oct-07 7:54 
AnswerRe: unhandled exception Pin
toxcct19-Oct-07 8:13
toxcct19-Oct-07 8:13 
GeneralRe: unhandled exception Pin
staticplus19-Oct-07 8:43
staticplus19-Oct-07 8:43 
GeneralRe: unhandled exception Pin
toxcct19-Oct-07 8:47
toxcct19-Oct-07 8:47 
GeneralRe: unhandled exception Pin
staticplus19-Oct-07 9:04
staticplus19-Oct-07 9:04 
This is my code which is probably causing the error:
void AsyncServer::InitSocks()
{
String* server = "CATUXPSD01";
int port = 4901;
printf("in InitSocks");
String* request = String::Concat(S"Our test data asdf");
Byte bytesSent[] = Encoding::ASCII->GetBytes(request);
Byte bytesReceived[] = new Byte[256];

Socket* s = 0;
IPHostEntry* hostEntry = 0;

// Get host related information.
hostEntry = Dns::Resolve(server);

// Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
// an exception that occurs when the host IP Address is not compatible with the address family
// (typical in the IPv6 case).

IEnumerator* myEnum = hostEntry->AddressList->GetEnumerator();
while (myEnum->MoveNext())
{
IPAddress* address = __try_cast<ipaddress*>(myEnum->Current);
IPEndPoint* endPoint = new IPEndPoint(address, port);
Socket* tmpS = new Socket(endPoint->AddressFamily, SocketType::Stream, ProtocolType::Tcp);
tmpS->Connect(endPoint);
if (tmpS->Connected)
{
s = tmpS;
break;
}
}

// Create a socket connection with the specified server and port.
if (s == 0) {
printf("Connection failed");
} else {
// Send request to the server.
s->Send(bytesSent, bytesSent->Length, static_cast<socketflags>(0));
}
}

So a socket is being created so I can send data. My problem is that when there is nothing listening on the port I don't want the program to generate the error, I want to trap the error and do something with it.
GeneralRe: unhandled exception Pin
toxcct20-Oct-07 3:10
toxcct20-Oct-07 3:10 
GeneralRe: unhandled exception Pin
super_ttd27-Oct-07 5:06
super_ttd27-Oct-07 5:06 
QuestionVS 2003 Find Results Keyboard Shortcuts Pin
Blake Miller19-Oct-07 7:50
Blake Miller19-Oct-07 7:50 
Questionabout STATIC TEXT in WIN32 API (C++ only) Pin
hkim_zoro19-Oct-07 7:06
hkim_zoro19-Oct-07 7:06 
AnswerRe: about STATIC TEXT in WIN32 API (C++ only) Pin
Jonathan [Darka]19-Oct-07 7:24
professionalJonathan [Darka]19-Oct-07 7:24 
AnswerRe: about STATIC TEXT in WIN32 API (C++ only) Pin
Hamid_RT19-Oct-07 19:09
Hamid_RT19-Oct-07 19:09 
QuestionMidistation Directx Pin
Rance_Wilson19-Oct-07 6:56
Rance_Wilson19-Oct-07 6:56 
QuestionDIRECTX DIRECT MUSIC MIDISTATION MIDI Pin
Rance_Wilson19-Oct-07 6:49
Rance_Wilson19-Oct-07 6:49 
Questionc++ options Pin
paulie5419-Oct-07 6:22
paulie5419-Oct-07 6:22 
AnswerRe: c++ options Pin
Mark Salsbery19-Oct-07 6:24
Mark Salsbery19-Oct-07 6:24 
AnswerRe: c++ options Pin
Nemanja Trifunovic19-Oct-07 6:38
Nemanja Trifunovic19-Oct-07 6:38 
GeneralRe: c++ options Pin
Jonathan [Darka]19-Oct-07 7:21
professionalJonathan [Darka]19-Oct-07 7:21 
GeneralRe: c++ options Pin
BadKarma19-Oct-07 7:39
BadKarma19-Oct-07 7:39 
AnswerRe: c++ options Pin
Hamid_RT19-Oct-07 6:58
Hamid_RT19-Oct-07 6:58 
QuestionCrash in CAsyncSocket::Close() Pin
Anorexic Tribble19-Oct-07 2:19
Anorexic Tribble19-Oct-07 2:19 
AnswerRe: Crash in CAsyncSocket::Close() Pin
led mike19-Oct-07 4:15
led mike19-Oct-07 4:15 
GeneralRe: Crash in CAsyncSocket::Close() Pin
Anorexic Tribble19-Oct-07 4:37
Anorexic Tribble19-Oct-07 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.