|
Assuming all your addresses are correct...
What happens if the second connect() call (of 4 you show)
succeeds? Then you try to connect again(?).
Take a look at your logic - why check for error on connect in some calls
and not on others?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok so picture a program trying to connect to a Domain
1: DNS
2: Connect
But somethings wrong with the site/domain/server. All it can do is DNS the domain and retrieve a IP address but cannot connect to it.
My code does just that. DNS, Connect. But if it cant connect the first server, switch to backup server1, if backupserver1 DNS's properly, but cannot connect, then switch to backup server2. Does this make sense?
|
|
|
|
|
Makes sense but the code shown has logic like this:
connect
If failed
connect
connect <font color="Red"><-- shouldn't connect here if previous connect succeeded</font>
If failed
connect when it should be
connect
if failed
connect
if failed
connect
if failed
connect
That's what I was referring to
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes! Thats exactly what i was refering to. And thats how it was. I maybe typed an extra character when i shouldnt have. Any suggestions?
|
|
|
|
|
The key point I was trying to make is that you need to check for success/fail on
all connect() calls.
You can code it any way you want. The simplest, least elegant way is nested "if"s
if (SOCKET_ERROR == connect(..))
{
... try next address
if (SOCKET_ERROR == connect(..))
{
... try next address
if (SOCKET_ERROR == connect(..))
{
... try next address
if (SOCKET_ERROR == connect(..))
{
// all four connect() attempts failed!
}
}
}
}
You can get as fancy as you want.
For example, a more elegant solution would be a configurable
list of addresses/server names that you loop through until
you get a successful connection.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Do you have a blocking or non-blocking socket?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No Mark Salsbery nested if's wont work either. They all seem to execute as long as connect() is in there.
DavidCrow, no i dont believe i have a blocking socket. This is really getting under my skin because i've been working on it too long. Any more ideas? If i put the if in a for loop then it would loop, maybe once, but i dont think it would still accomplish the goal. I'll test it to see.
|
|
|
|
|
dellthinker wrote: DavidCrow, no i dont believe i have a blocking socket.
So did you read the documentation on how connect() behaves with non-blocking sockets?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I take that back, the nested if's worked. Thanks. Sorry for the mistake
|
|
|
|
|
I am providing CD/DVD burning option for one of my applications. I have purchased Magic CD/DVD burning component. Using this component, I am able to write the data onto CD/DVD, but I am not able to write files with large filename onto the disc.
Is there anyone who has used that component earlier. Can anyone give me any suggestion so that I can write the files with large filename onto CD-DVD.
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
vijay7173 wrote: Can anyone give me any suggestion so that I can write the files with large filename onto CD-DVD.
Assuming you're burning in ISO-9660, I would suggest either level 2 or Joliet extensions or both. Level 1 and/or no Joliet extensions will mean you can only support 8.3 (DOS style) filenames. I'd like to think this library would give you the option to choose the file system extensions to use, so I'd say check their docs for it.
|
|
|
|
|
Jeremy Falcon wrote: I'd like to think this library would give you the option to choose the file system extensions to use, so I'd say check their docs for it.
yes, this is exactly what i am searching for at this moment. But there is no enough documentation given on this by them. I am trying to ask them but most of the links on their site is down. Anyways, I have sent a mail to their support team and hoping to get a reply soon. In the meanwhile, I wanted to know if any of the CPians here have used that component and wanted to know if they can help in anyway.
well, thanks for the reply, sir. Hope I can get more help here.
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
I have a DLL project being developed in Visual C++ 6 . Now the project has two configurations release and debug.
As part of the output a .lib is also created which is needed by the application trying to use the library.
I need to distribute files related to this DLL to the end user . Now does it matter for the .lib file ( for linkage) if this is debug or release . In other words will it suffice if I provide only the release .lib file even if the debug version of the DLL is going to be used ? Does it matter if you link with debug or release .lib fi
Engineering is the effort !
|
|
|
|
|
act_x wrote: Now does it matter for the .lib file ( for linkage) if this is debug or release .
Yes. Use the debug version of the .lib for the debug .dll, and the same goes for the release versions. Don't mix and match the two unless you want some strange errors creeping up.
|
|
|
|
|
Also you should get into the habit of appending (post fixing) a letter 'd' at the end of the debug lib filename to distinguish it from the release version. i.e
release name: utils.lib
debug name: utilsd.lib
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
also, in the properties tab, there is a macro $(ConfigurationName) it will associate debug files for debug build and release files for release. checkout the different macros, they can help a lot with different configurations or different file paths for different configurations.
[Insert Witty Sig Here]
|
|
|
|
|
I'm dumping values from an array to a file,
like
<br />
typedef int** _2dArray;<br />
_2dArray pIntArray[10];<br />
I can traverse through all the pointers in 'pIntArray' and make a call like
<br />
loop<br />
{<br />
fwrite((void*)&pIntArray,sizeof..,fp);<br />
}<br />
this will write down all the values every pointer in pIntArray is pointing too.
That's fine.
I had to include some more values while dumping these integers. Without thinking about it twice, I implemented a struct all accross like,
<br />
struct mystruct<br />
{<br />
int myval1;<br />
int myval2;<br />
_2dArray* arr2D;<br />
}<br />
mystruct myst;<br />
myst.myval1 =10;<br />
myst.myval2 =20;<br />
myst.arr2D = [another-pointer-to-intpointers.]<br />
And made a stupid implementation like,
<br />
fwrite((void*)&myst,sizeof..,fp);<br />
Crap! This wont work cuz it's a pointer! it wouldn't be dumped with it's content. .. can someone help me out to get away with this design and still manage to dump it's content? sounds stupid, ok tell me what'd be your way to implement it? But please note, with a single stretch, I should be able to fetch all these values with an fread()
Jemmy : Deadline? Pfft, a real programmer eats deadlines for breakfast. :P
Mark: I thought real programmers ignored deadlines
Best wishes to Rexx[^]
|
|
|
|
|
VuNic wrote: But please note, with a single stretch, I should be able to fetch all these values with an fread()
There's no way I know of for getting around it. arr2D can't be a pointer when its time to serialize.
VuNic wrote: Jemmy
That my new nickname?
|
|
|
|
|
Jeremy Falcon wrote: That my new nickname?
Mine is Mary apparently
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Mine is Mary apparently
|
|
|
|
|
I thought of putting you as "Maakie"
Jemmy : Deadline? Pfft, a real programmer eats deadlines for breakfast. :P
Mark: I thought real programmers ignored deadlines
Best wishes to Rexx[^]
|
|
|
|
|
No, that's my friend's name. Who lives in the US, and has a bird's name as his family name.
Jemmy : Deadline? Pfft, a real programmer eats deadlines for breakfast. :P
Mark: I thought real programmers ignored deadlines
Best wishes to Rexx[^]
|
|
|
|
|
VuNic wrote: No, that's my friend's name. Who lives in the US, and has a bird's name as his family name.
I've heard of that guy before. I hear he's a PITA.
|
|
|
|
|
Jeremy Falcon wrote:
I've heard of that guy before. I hear he's a PITA.
Exactly
Jemmy : Deadline? Pfft, a real programmer eats deadlines for breakfast. :P
Mark: I thought real programmers ignored deadlines
Best wishes to Rexx[^]
|
|
|
|
|
VuNic wrote: Exactly
|
|
|
|