|
Yeah, I picked up that little mistake when the compiler started throwing unexpected tokens at me LOL!
|
|
|
|
|
can anyone explain how to use tcp in C++ I've looked at a million sites and a million tutorials and every single one doesn't work.
|
|
|
|
|
mmavipc wrote: how to use tcp
What do you mean? Doesn't socket solve your questions? There are plenty good articles around socket here in CodeProject.
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
mmavipc wrote: I've looked at a million sites and a million tutorials and every single one doesn't work
Good thing you came here then! There's plenty of articles available here and I bet most, if not
all, of them work
As mentioned, sockets is the easiest way to get started with TCP.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
I've looked at many tutorials on this site. and none of them work(-_-") all the examples give compile errors
|
|
|
|
|
mmavipc wrote: I've looked at many tutorials on this site. and none of them work(-_-") all the examples give compile errors
what type of compiler error!
|
|
|
|
|
Have you found a solution yet?
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Hello everyone,
i am writing a program uses shared memory with semaphores and i use fork() mechanism for child process.
My program will run until the user hits ctrl+C.
But when it is hit, i must stop the child process, detach and deallocate the shared memory and then exit. How can i achieve this?
i tried signal and defined a handler function but i cannot pass any other necessary arguments to it. It takes only one int signum. Do u have any suggestions?
Thanks in advance.
|
|
|
|
|
How to make the edit control look like the format( : : : ) eg-> 12:15:03
There should be possibility of editing values but those colons should remain permanent.
any answers are appreciated.
|
|
|
|
|
Are you trying to store or present Time? Are you using MFC?
Why don't you use Date Time picker . Setting properties can display exactly such a control. If you need CString, it's as simple as using methods of the control(eg. str.Format("%02d:%02d:%02d", myTime.GetHour(), myTime.GetMin... ); ). The control has also a Format function. If you are not going to show Time, then you can derive a new class from CEdit and overload it's painting function.
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Super Hornet wrote: any answers are appreciated.
you have to write your own CEdit derived from CEdit class!
|
|
|
|
|
hi iam making a program to implement pwd command under unix environment.. but the result is always segmentation fault, i think my code is alright, can you give me a solution? thanks
#include<stdio.h>
#include<sys stat.h="">
#include<sys types.h="">
#include<pwd.h>
#include<dirent.h>
#include<grp.h>
#include<stdlib.h>
#include<string.h>
int main()
{
struct dirent *ds = 0;
DIR *dirp = 0;
struct stat sbuf;
char pathname[1024];
char *dirname;
struct passwd *pw;
struct group *gr;
dirname = ".";
dirp = opendir(dirname);
if(dirp)
{
strcpy(pathname,dirname);
strcat(pathname,"/");
strcat(pathname,ds->d_name);
lstat(pathname,&sbuf);
pw = getpwuid(sbuf.st_uid);
gr = getpwuid(sbuf.st_gid);
printf("%-8s \n",pw->pw_dir);
}
return(0);
}
|
|
|
|
|
You missed the forum (this is not Linux related).
Anyway I'll try to help you.
You forgot to allocate memory for ds variable. This may cause troubles to strcat(pathname,ds->d_name); .
Hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
btw, what's a pwd command?
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
From Linux man:
Pwd
Print the full filename of the current working directory.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Okie okie
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
In a project I use CAsyncSocket to connect 2 computers. If after the connection established, I disconnect the wire between the 2 computers, applications does not show any sign of a disconnection
I tried sending and receiving messages after disconnection several times, but non of applications notice any change until I reconnect the wire, at this point Send returned an error code.
Is it my fault or it's a usual behavior? How to recognize network failures if there is not an event available(On Disconnect doe's not work)? Is it good to continually check connection in a thread?
-- modified at 10:34 Sunday 1st April, 2007
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Hamed Mosavi wrote: Is it my fault or it's a usual behavior?
No it's not your fault!. TCP protocol has been designed in such a way. Sometimes it really looks stupid. You can never know if the client is not alive at the other end when there's a n/w distruption occurs. It's done because, there may be flucuations in the n/w then and there if all these are reported as disconnect events, this would degrade TCP. So it abstracts the disconnections to the user. Still not completely sure why they dont do it!.Implement a "ping" like solution to your problem. The server sends "Are you there" periodically to the clients and the clients "must" reply to the question. If it doesn't then it's not there. In short you are making your own *protocol* to overcome this handicap in TCP.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Thanks
VuNic wrote: n short you are making your own *protocol* to overcome this handicap in TCP.
I just thought about that when said: "Is it good to continually(periodically is much better word here as you suggested) check connection in a thread?"
This will solve my problem, but this increase workload significantly if I wanted to connect a server to a large group of clients and also may increase expenses extensively. Doesn't it?
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Hamed Mosavi wrote: check connection in a thread?"
Exactly. But you can still do it with timers but for console applications, threads would be prefered. Otherwise you need to implement callbacks& message loops.
Hamed Mosavi wrote: but this increase workload significantly
Yeah it certainly is an overhead. But I haven't seen any visible degradation in the system. We can do like this. You can maintain a data structure that keeps track of "last" response recieved from the clients. Rather than sending ping to all clients, you traverse thru the container(data structure that you maintain to keep track of client event times) and send ping request only to clients that has not sent any messages for so long. This way you can reduce the overhead.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Thank you very much. It was informative.
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
You are welcome Hamed
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Hamed Mosavi wrote: s it my fault or it's a usual behavior? How to recognize network failures if there is not an event available(On Disconnect doe's not work)? Is it good to continually check connection in a thread?
IsNetworkAlive
|
|
|
|
|
Great, But what if the computer is connected to multiple LANs simultaneously?
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Hi,
You u can have ur application specific protocol, say keep alive protocol which will send heart beat or a dummy message after every pre - determined interval of time. If the send fails u can get the reason in GetLastError and determine if the client is still alive (connected to network )or down.
Get the facts or facts will get you and when you get them, get them right or they will get you wrong.
Happy Coding
|
|
|
|