|
Hi guys,
i am new to this group. i m facing a very serious problem with my project.
the details of the project are
1) we basically need to develop a client which is kind of a messenger
service something like yahoo.
2) it is based upon Jabber Technology. though there are a lot of
clients already present on this technology we want to develop a client
which is for an embedded device and not primarily for a web browser.
this is the basic reason why we want the program to be written on ANSI
C.
3) the platform on which we have to work and run this program is Visual C
4) what we have done till now is done coding for a
1) Client to Server communication and
2) Server to Client communication
3) some coding for multithreading with 1 or 2 errors
5) what is required now is to develop from this a multi threading
program which will enable us to communicate from Client to Client
through a server. this is the most primary requirement
after which XMPP protocol needs to be added
i am stuck with the multithreading part and this being my first project i really dont know how to go about it. i m really short of time and have a deadline of end of this month to submit this project. i really forward to help from you guys for my problem. in case of any further details about the project i would be more than happy to let u all know.
i am sending the multithreading program which gives few errors wn i build it. if you can solve that n make it working that would be awesome but even a new multithreading program would serve the purpose.
i really hope that i would get some help from you guys soon.
awaiting reply from you all
Regards,
S.Arunesh
|
|
|
|
|
Please post specific questions
|
|
|
|
|
|
there were some mistakes in previous program regarding header files. i am posting it again
#include<sys types.h="">
#include <winsock2.h>
//#include <process.h>
#include<windows.h>
#include<stdlib.h>
#include<stdio.h>
#include <stddef.h>
#include <conio.h>
void CheckKey(void *);
void main()
{
int cont,create_socket,new_socket,addrlen;
int bufsize = 1024;
char *buffer =(char *) malloc(bufsize);
struct sockaddr_in address;
WSADATA wsaData;
if(WSAStartup(0x202,&wsaData) == SOCKET_ERROR)
{
return ;
}
//printf("\x1B[2J");
if ((create_socket = socket(AF_INET,SOCK_STREAM,0)) > 0)
printf("The socket was created\n");
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(15000);
if (bind(create_socket,(struct sockaddr *)&address,sizeof(address)) == 0)
printf("Binding Socket\n");
int retval =listen(create_socket,SOMAXCONN);
addrlen = sizeof(struct sockaddr_in);
DWORD ThreadId;
HANDLE hWnd;
hWnd =CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CheckKey,NULL,0,&ThreadId);
//CreateThread(CheckKey, 0, NULL );
new_socket = accept(create_socket,(struct sockaddr *)&address,&addrlen);
if (new_socket > 0){
recv(new_socket,buffer,bufsize,0);
printf("The Client %s is connected...\n",buffer);
//for(cont=1;cont<5000;cont++)
// printf("\x7");
}
do{
printf("Message to send: ");
gets(buffer);
send(new_socket,buffer,bufsize,0);
recv(new_socket,buffer,bufsize,0);
printf("Message recieved: %s\n",buffer);
}while(strcmp(buffer,"/q")); //user 'q' to quit
//close(new_socket);
//close(create_socket);
}
//void CheckKey()
//{
// new_socket = accept(create_socket,(struct sockaddr *)&address,&addrlen);
// if (new_socket > 0){
// printf("The Client %s is connected...\n",inet_ntoa(address.sin_addr));
//for(cont=1;cont<5000;cont++)
// printf("\x7");
// }
//}
/*void CheckKey(void * val)
{
while(1)
{
new_socket = accept(create_socket,(struct sockaddr *)&address,&addrlen);
if (new_socket > 0)
{
recv(new_socket,buffer,bufsize,0);
printf("The Client %s is connected...\n",buffer);
}
}
return ;
}*/
//DWORD WINAPI ValidateData(LPVOID Parameter)
//{
//Get the information about client entity
//SOCKET client = (SOCKET)Parameter;
//int rVal; //Return val
//char buf[11]; //used to send the validated data to client
//Get the data form client
//rVal = recv(client,buf,11,0);
//here we are performing simple check, the data came form client
//is valid or not
//at this point you can check your own data also, which needs some modification
//if(strcmp(buf,"Data On Socket"))
//{
//Send back the data to the client
//rVal = send(client,"YES",3,0);
//}
//else
//{
//Send back the data to the client
//rVal = send(client,"NO",2,0);
//}
//return 0;
//}
|
|
|
|
|
dont know why the header files go missing every time. i am sending them again. hopefully it gets posted this time
#include <sys types.h="">
#include <winsock2.h>
//#include <process.h>
#include<windows.h>
#include<stdlib.h>
#include<stdio.h>
#include <stddef.h>
#include <conio.h>
|
|
|
|
|
when posting a message you should replace the < & > with HTML compatible versions. Under the text box, above the smilies there are Formatting tags to do this for you. Here you will also find the <pre> & </pre> tags for entering "readable" code.
|
|
|
|
|
Please, read this post[^] before posting. Use the pre and code tags.
seekin_nirvana wrote: there are no errors while compilation but while building 2 errors crop up
What do you mean by building ? Are you talking about linking errors ? If yes, post the exact error message.
seekin_nirvana wrote: so it would be really great if any1 could do that
Nobody here will do the job for you. People are here to help each other, not to work for the others.
|
|
|
|
|
sorry dude if u felt i was too demanding regarding help. its just that my situation is soo bad. thats y........ anyways any kind of help frm you would be really valuable to me
here is the exact problem obtained while linking. hope you would be able to resolve it.
Linking...
multithread.obj : error LNK2001: unresolved external symbol "void __cdecl CheckKey(void *)" (?CheckKey@@YAXPAX@Z)
Debug/multithread.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
multithread.exe - 2 error(s), 0 warning(s)
|
|
|
|
|
You have a declaration of your CheckKey function but there is on definition (they are all commented out). So, that's why you don't have an error at compile time (the compiler suppose the function is defined somewhere because you have declared it) but the linker is unable to find the definition, thus throws an unresolved symbol. Provide a definition to the function and this will solve your problem.
|
|
|
|
|
Also, don't go around casting things to make the compiler shut up unless you know what you are doing. You've cast your CheckKey function which has a signature of void __cdecl (void *) to LPTHREAD_START_ROUTINE which is DWORD __stdcall (LPVOID lpThreadParameter). This is a recipe for stack corruption.
|
|
|
|
|
If you haven’t got experience with multithreaded programming and you're on a deadline then multithreaded is not an option. Writing multithreaded programs is hard, debugging badly written multithreaded programs is, at times, next to impossible. Don't paint yourself into a corner.
Steve
|
|
|
|
|
I have a dialog template which I use for 3 seperate functions
1. Display data (all edit fields set to read-only).
2. Edit data (enable edit controls, display data and process input).
3. New Data (enable edit controls, initially set to empty and process input).
Now lets say the user calls 'Display data' then decides they want to edit something. Well I have an edit button, but the callback does not process the edit fields. At the moment it closes the dialog and returns a value indicating users choice, the main loop then opens 'Edit data'.
It works but I'm sure it could work better. When the switch occurs the size and position is reset.
Now the callback function is simply a pointer, is it possible to change the callback pointer from the dialog when the user hits the edit button?
|
|
|
|
|
waldermort wrote: is it possible to change the callback pointer from the dialog
SetWindowLong()
I think you should reconsider your design and have one dialog procedure that handles all three cases depending on a flag. It is easier to change a flag then it is to switch dialog procedures.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Your right, it's proving to be a little more troublesome than its worth. The three procedures are infact quite large, when I initially created them I intended for them to do completely different tasks. Adding this Edit button was an after thought.
Combining them now into a single callback would be even more hassle. I will leave it as it is I think and maybe make the change in the next version.
Thanks for your reply.
|
|
|
|
|
i want open a url through programming for this i am using shellexecute function and open web page on default browser but problem is that i want to open this page only on internet explorer only instead of default browser .
if any have idea about this please share with me :its urgent
Bankey Khandelwal
Software Engineer
|
|
|
|
|
instead of "open" ing your "url.htm" , call this :
::ShellExecute(NULL, "<code>open</code>", "<code>iexplore.exe</code>", "<code>your_url.htm</code>", NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
but i have to show web page to the user only on enternet explorar
Bankey Khandelwal
Software Engineer
|
|
|
|
|
hey, have you tried what i answered ?
if yes, what is the problem ?
|
|
|
|
|
thank you ,i think its done but i don't have any other default browser.
Bankey Khandelwal
Software Engineer
|
|
|
|
|
install FireFox and set it as the default browser to test...
|
|
|
|
|
it seems that u hav not read v2.0's answer properly.
there he have clearly mentioned the 3rd param of shellexecute as "iexplorer.exe"
which means Internet explorer.
You can see help about Shellexucute at msdn's site.
Otherwise just try what he had suggested I should work. :->
|
|
|
|
|
Hello to all Gurus.
Here is a question for all of u, please help me.
Many of u might have seen Outlook Express.
In that at right hand side they have provided a window as "Tip of the Day"
with a "Previous" & "Next" button at the bottom.
Same thing I have done. Iam developing an application in MFC.(VS 2005)
I have designed the page in HTML and Iam using CDHTMLViewSpec class to catch the link which was clicked by the user.
I am showing several link at left side of the page & a "Help" window at right side of page,
which is same as "Tip of the day" window of Outlook Express.
The problem is that when user clicks a perticular link from left side it's contents does get displayed in help window but if the content is too large user has to scroll down
which i don't want.
In outlook express they have provided "Previous" and "next" links.
I want to know how to keep track of the information displayed so that user doesn't need to scroll down & he can see the help in sections by clicking on "Previous" and "next".
and how to determine that the help about a perticular link is over so help about next is to be displayed.
Please someone help.
Thank you.
|
|
|
|
|
why don't you create a vector with a name of lets say history. When the user clicks a link add the info to the vector. Then for the 'next' and 'back' buttons its a simple matter of iterating through your vector and displaying the relevent page.
If I understand your second question correctly. You need to break your page into viewable sections. and simply count how many you have. If page ID is 0, then disable the back button. If page ID is MAX_COUNT disable the next button.
|
|
|
|
|
Thank u Waldermort your answer gave me some Idea.
but can you tell me how to break the page into "viewable sections" (if u can gv a code snippet)or can refer to a site plz do the fewer for me.
Thank u for ur concern.
|
|
|
|
|
Really it depends on the data you are trying to display. But lets say for now it is only lines and lines of text, and you want to break it into sections. You have to take into account 2 things, the font size and the screen resolution. A font of size 12 will appear a lot smaller on a 1024*768 resolution than it would on a 800*600.
So to calculate this you need to use the GetDeviceCaps() function to find out information about the screen. And create a suitable font by passing it the value of the this function. Try searching for some printing tutorials, they will help you understand this. Here is a good one[^]
Another method is to draw the text. Often with Tip of the Day, the text is drawn onto a yellow background. So you could create a bitmap, and draw text onto it using DrawTextEx(), then resize this bitmap according to your display needs. The only drawback here is that if you create a small bitmap, the text may become distorted when resizing. My first method is the best.
-- modified at 8:50 Thursday 23rd March, 2006
Corrected the function name.
|
|
|
|