|
Converting from global(static) calling conversions to this-call,
van be made by using Boost library templates.
Find on the www this very widely used library.
___________
Problem not in direct performance but in delays that can cause killtimer,
to up to period of timer
that is already big performance - die.
|
|
|
|
|
Hi all,
New to programming, writing my first app using TCP.
I need to make a client server that will send messages to a server. Right now i have two dialog windows. One that takes in the IP that the user wants to connect to(Connection), and another window where the user will set the information that will be sent (Format_Msg). I would like to have a third window that tells me what is sent over and what it receives.
I can get the app to connect to the server, I just can not send the appropriate messages over to the server. I do all the connecting and instantiate a socket called ConnectServer in the Connection class. I do all the formatting of the message in the Format_Msg class.
my question is how do I send these messages now? I am trying to use the:send (SOCKET s, const char FAR * buf, int len, int flags) command but don't know what I am doing wrong.
Can I use the same connection that I made (ConnectServer), or do I have to instantiate a socket in the Format_Msg class too? If I don't, could you please tell me how I could get it to recognize the other socket that was instantiated in the Connection class?
If you have code to how i could do this, it would be great.
Many thanks in advance.
|
|
|
|
|
|
Hi,
I read those articles, thats how i got the app to connect to the server.
I am still having problems sending the information though. I don't know if I should be passing in the same connection or instantiating a new one in the second class. Don't know how to use the same connection actually. Can anyone help me with that?
Thanks in advance.
|
|
|
|
|
you mean you've opened a tcp connection to a server and want to send data through?
easy...
send( tcpsocket, buffer, len, 0 );
Don't try it, just do it!
|
|
|
|
|
yes that is what i want to do.
Only thing is that I create the socket in one class and want to format a message before I send it, which is done in another class. I do not know how to get the same socket that I created in the first class to be used in the second class. If i try and use the same socket, it will give me an error saying that it is a undeclared identifier.
Thanks for your help. I know it is probably a simple question, but I am a newbie with program. (Trying to change my career and learn something new)
|
|
|
|
|
I presume that you are declaring an instance of the "formatting" class inside the class with the "working" socket???
If you are just add a socket variable to the formatting class and overload the constructor of the formatting class so that when you are creating the formatting class object just do somerhign like this:
MyFormatClass mfc = new MyFormatClass(socket);
Or else you could make the socket variable in the format class public and just set it like:
MyFormatClass mfc;<br>mfc.socketvar = this.socket;
But without knowing more about your code and the way your classes work/interact I can't give a definite answer.
Regards,
Brian Dela
http://www.briandela.com[^]
|
|
|
|
|
Thanks for the help Brian.
I am really new to programming, and do not understand how to do what you are telling me.
How would I declare an instance of the "formatting" class inside the class with the "working" socket?
What other information do you need to know about my program?
Many thanks in advance.
|
|
|
|
|
You said you have a class that formats the string, yeah? ... Unless it is a static function within the class that you are using (i.e. you would be doing something like MyFormatClass::FormatString(string); .
Otherwise you have to do something like:
MyFormatClass mfc;
or
MyFormatClass* mfc = new MyFormatClass()
Are you doing anything like this???
If you want, email me on the code.
Regards,
Brian Dela
http://www.briandela.com[^]
|
|
|
|
|
Hi
I´m new to C++ and working with passing files back and fourth to a webservice. I have found som code in C# that does this for me but I can´t convert it into C++. Can someone please help me with the two last lines?
DimeAttachment attachment = new
DimeAttachment("application/octet-stream", TypeFormatEnum.MediaType, ms);
HttpSoapContext.ResponseContext.Attachments.Clear();
HttpSoapContext.ResponseContext.Attachments.Add(attachment);
Regards
// Daniel
|
|
|
|
|
Do u know a func. like scanf() which works in C's graphic mode? ( I can't position the cursor with gotoxy() command while using scanf() func in graphic mode.)
note:i am using Borland TURBO C++ v.3.0
|
|
|
|
|
sscanf
Don't try it, just do it!
|
|
|
|
|
I need to use the sqrt() function in <cmath> in one of my functions in a Windows program using MFC. At the top of the file I put in these lines:
#include <cmath> <br />
using std::sqrt;
and I got this error:
error C2653: 'std' : is not a class or namespace name
Why doesn't the compiler recognize the std namespace?
|
|
|
|
|
It's odd that it does not work. As a workaround, use the C-standart function.
<br />
#include <math.h><br />
...<br />
double x = sqrt (y);<br />
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Thanks, I did that.
I'm using VC++ 6.0 if that helps.
|
|
|
|
|
Try:
#include <cmath>
using namespace std;
...
// use the sqrt func
float x = sqrt(y);
or you can just call the sqrt function without the "using" keyword:
#include <cmath>
...
// use the sqrt func
float x = std::sqrt(y);
HTH.
David Hisel -- http://www.hisel.com/
|
|
|
|
|
I tried both of those, but as expected, I get the same error--my compiler does not recognize "std" as a namespace.
My compiler does recognize "std" as a namespace for win32 console apps, but not this, my first win32 with MFC app attempting to use the std namespace.
|
|
|
|
|
The things I will say in this reply are MS Visual C++ 6.0 specific. I have not tried them on any other compiler.
7stud wrote:
My compiler does recognize "std" as a namespace for win32 console apps
You probably use #include <iostream> , which includes the std namespace. But, the cmath header file does not contain the std namespace. In fact, the following code is perfectly legal:
#include <cmath>
int main() {
double x = sqrt(5);
}
But this one is not:
#include <cmath>
using std::sqrt;
So you don't need to use the std namespace if you are going to use cmath in Visual C++ 6.0.
Hope this helps.
Hosam Aly Mahmoud
|
|
|
|
|
Thanks for the explanation.
|
|
|
|
|
You're welcome.
Hosam Aly Mahmoud
|
|
|
|
|
How do you get the current time of the machine in milliseconds.
I have used the time() function from time.h before but that only gives me back up to the seconds..
Any ideas would be great - thank you
|
|
|
|
|
Try _ftime .
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
GetLocalTime
Don't try it, just do it!
|
|
|
|
|
I do not know of a time function that returns the milliseconds. If, however, you are looking for a stopwatch function, you may give CWnd::SetTimer / CWnd::KillTimer a look. However, be forwarned that even though it boasts triggering off of microseconds, it does not guarantee accuracy... quote from MSDN
"Because the accuracy of a timer depends on the system clock rate and how often the application retrieves messages from the message queue, the time-out value is only approximate."
I apologize if this suggestion isn't even remotely close to what your looking for.
|
|
|
|
|
Hi
I have this program which reads/write some things from/to registry, but i have no idea what it exactly reads/writes in the registry when it gets launched.
Is there any utility to monitor what a program exactly does when it gets launched, registry is only one of the things that can be monitored.
Anyone knows?
Greetings
Jens
|
|
|
|