|
|
Hello ppl
following is the code snippet
if(!AfxSocketInit())
AfxMessageBox("Socket Init Error");
if(mysocket.Create(6000,SOCK_STREAM) == TRUE)
AfxMessageBox("Socket Created");
if(server.Create(3000,SOCK_STREAM) == TRUE)
AfxMessageBox("Server Socket Created");
if(server.Connect("172.16.65.122",6000) == TRUE)
AfxMessageBox("Connected to client");
else
{
int a = server.GetLastError();
AfxMessageBox((CString)a);
}
what i am trying to do here is that i need to connect to the same machine using socks for that reason i have created two sockets one that actually should act as a client and other as a server now both the sockets are created successfully but server is unable to connect to the client (remember client is the same machine as server) the error no that is returned is 3 and i dont know what it means please help me out i am a socket newbie
thanks
|
|
|
|
|
if i read well ur server is connecting to a client???
this is odd
try that the client connects to the server
the server must be listening to its socket
(look at Listen and Bind)
i recomand you to look for NDK on CP
anyway the error code 3 means "The system cannot find the path specified. ERROR_PATH_NOT_FOUND"
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i want to have a lable with arabic font but the studio does'nt support arabic fonts how could i have a lable or menue with arabic fonts?
|
|
|
|
|
|
Have you got "wWinMainCRTStartup" as your "Entry-point symbol" ("Output" category of "Link" tab on project settings dialog) ? I had some linker errors when first building for unicode and I found that fixed it.
|
|
|
|
|
I just got Visual C++ .NET tonight and I started messing around with it. I'm a java developer and have been kind of curious of the .NET I'm really stuck i've search google.com but the word .NET brings up alot of junk. I'm stuck on declaring a function not sure how. I keep getting an error (error C3602: 'String': a __gc type object cannot be passed by value) It's right when I pass it to the function that will make the string to uppercase. Not sure what it means a __gc could someone help me out or show me where i can look at some online docs for newbies thanks.
<br />
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)<br />
{ <br />
this->label1->Text = this->textBox1->Text;<br />
this->strBox = this->textBox1->Text;<br />
this->upperCase = this->makeUpperCase(strBox); <br />
this->daString(upperCase);<br />
}<br />
<br />
public: System::Void daString(System::String * blah)<br />
{<br />
MessageBox::Show(blah,S"Testing Function daString", MessageBoxButtons::OK, MessageBoxIcon::Information);<br />
}<br />
<br />
String makeUpperCase(System::String * upper)<br />
{<br />
return upper->ToUpper();<br />
}<br />
<br />
private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e)<br />
{<br />
MessageBox::Show(S"Message Box Demo",S"My Application", MessageBoxButtons::OK, MessageBoxIcon::Asterisk);<br />
}<br />
<br />
};<br />
}<br />
<br />
<br />
|
|
|
|
|
If you look closely, the String::ToUpper function returns a String*, whereas you are using a String return type.
Try
String* makeUpperCase( String* inString )
{
return inString->ToUpper();
}
There are minor differences between C++ and C++ .Net. C++ .Net compiles to MSIL code, and it has introduced the concept of garbage-collectable (__gc) classes. Since System::String is a __gc class, and not a value type like an int, so you can only use pointers to it in your code.
|
|
|
|
|
As an accomplished Java programmer you should consider C# as an option. You would have a much easier time learning it than managed C++. But everything depends on what you want to do.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
Hi all,
Need some help with an MFC dll I have.
I'm connecting/disconnecting to a database using two simple functions.
__declspec(dllexport) void Connect()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
database.Open( "EmployeeManager" );
}
__declspec(dllexport) void Disconnect()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
database.Close();
}
database is declared as global so I can access it all through the dll.
The problem is coming when I exit from the program using the dll. It throws a memory exception. I can't figure out why. I know its a problem with the connection because I tested just opening and connecting, then quitting and the error only occurs if I'm connected. I get an error regardless of whether or not I call disconnect on exit. Any ideas?
Mike
|
|
|
|
|
Did some more testing. The actual error I'm getting is "Exception Breakpoint A breakpoint has been reached."
This occurs only in debug mode. The release has no errors. I can't find any breakpoints anywhere so I still have no idea what's going on in debug mode.
Mike
|
|
|
|
|
A breakpoint is reported to the debugger by raising a STATUS_BREAKPOINT exception, code 0x80000003. If the debugger is not expecting it (i.e. there is no breakpoint on that instruction), it will report the exception to the user.
The system's heap manager will generate such an exception if it discovers, on freeing a block, that the block has become corrupted. I suggest using the gflags utility to enable page granularity heap allocations, where the heap manager allocates two pages per heap allocation. The first page contains your allocated block (allocated at the end of the page), and the second page is marked no access. When you overflow a heap buffer, you get an immediate access violation at that point.
IIRC, the heap manager by default only does heap checking if the executable image has the DEBUG flag in the header. VC's linker adds the DEBUG flag for a debug build.
To set up gflags , run it as an administrator, enter the name of your executable in the 'Image File Name' box, then choose the 'Image File Options' radio button. Check the 'Enable page heap' box and click OK.
|
|
|
|
|
Ok I did that and it gave me an access violation. Doesn't really help me though. First off I'm not real good at debugging, so unless its an obvious problem, doing something like you suggested doesn't help me much.
It's still the same thing that's causing it. When I try disconnecting from a database from my dll. It really doesn't make any sense to me. It worked before when I opened and closed the database from within an exported function. Then I decided it was a waste of resources to open and close each time I wanted to access it. So I declared a global instance of a CDatabase class.
I connect once at program initialization and then call disconnect at close. Seemed pretty simple to me, but now its throwing an exception for no apparent reason. The only solution I can think of is to go back to the old way of opening and closing the DB each time I access it.
Mike
|
|
|
|
|
I found a simple bug in VS.NET 2003 for C++...
the following cout statement
cout << "tetete??(tete";
would print
tetete[tete
It appears that it translates ??( as a square bracket....
My regional settings are English (US) .Just wanted to share this.
take care
|
|
|
|
|
That's not a bug. There are certain three character combinations (or trigraphs), all of which begin '??' which then map to a single character during a compile.
This is so you can write C (or C++) code even if your character set doesn't have # [ \ ] ^ { | } or ~
Steve S
|
|
|
|
|
I use the HTMLHelp API to display the compiled HTML help file (.chm) in VC++ 6.0. It works fine. But when I try to run the same source code under .net environment, the compiler complains that the HTMLHelp does not take four argument. I thought that the VS .net 2003 converts my VC++ 6.0 project to VC++ .net automatally. But it seems not the case. Basically I want to display my help.chm file in my VC++ application in .net. Thanks for the help.
Hei Lam
|
|
|
|
|
It's me again! May I know how I can change the size of the console window using VC++ 6.0? I understand I can change it manually at the console window, but is it possible to do such coding? Thank you!
|
|
|
|
|
My program calls AsfCut.exe using the CConsolePipe class available here. But, asfcut is returning an error, and when my error-handling code starts (in the app's main thread, called using SendMessage from the asfcut-calling thread) it does "char *tmp = new char[350];", which returns this exception:
Unhandled exception at 0x77e73887 in IGCProcessor.exe: Microsoft C++ exception: std::bad_alloc @ 0x00116b04.
I have plenty of memory available, and my program is only using about 3mb according to Task Manager, so what in the world could be causing that exception?
|
|
|
|
|
I've found out that even calling "char *tmp = new char[xxx];" right after calling "myConsole->Execute(cmdLine);" crashes, though with a access violation at 0x000000 in strlen. Weird
|
|
|
|
|
Nevermind, there was a buffer overrun on a char array in Execute() . Not sure why it didn't give me a more informative error message, though
|
|
|
|
|
If anyone has experience using InstallShield Developer, I've posted a request for information on my forum here[^]. Thanks for your help.
Software Zen: delete this;
|
|
|
|
|
Hey I need help I am going to make a program in Visual C++ V6. I am ok at dialog based programs but I need this one to have the look, or layout of the well, like front page, or more or less the way microsoft visual c++ is laid out. One split panel on the left. One split panel on the bottom, and a place for documents in the middle. I want to be able to refrence a data base and I want to use dlls as much as posible for add ons and upgrades. I am not sure when starting the New MFC project, which one I should select. I know to go for a multiple document thing, but as far as the rest of the choices are concerened I am not sure. I want to make sure I am starting in the right place though, so can someone help me here?
Thanks
LOSTTWARE.com
|
|
|
|
|
Just go with an MFC exe file and select MDI. Use full database support when prompted.
BTW - Your site was asking about how to to better promote itself. I would suggest posting programming questions to hi-traffic programming sites and using your domain name as your username.
BTW2 - The technique of sending yourself a letter via certified mail to prove that you thought of an idea first doesn't work because you can send yourself an unsealed envelope that can be filled with whatever idea you want to rip-off and seal it long after you sign for it.
BTW3 - You don't even have Code Project listed as a programming resource on your link list.
|
|
|
|
|
RE to BTW2:
I have used it, and it did work, on a copyright.
RE to BTW3:
I have not added them, because I just found them.
LOSTTWARE.com
|
|
|
|
|
LOSTTWARE.com wrote:
RE to BTW2:
I have used it, and it did work, on a copyright.
Seems strange. I mean, I could send myself an empty envelope now and next year fill it with whatever new idea just popped up, seal it, and then say I thought of it first.
|
|
|
|