Solved

Chat Software to be deveoped in VC++ within one week

Posted on 2004-04-06
8
160 Views
Last Modified: 2010-04-01
Hi all,

I know c, c++ and vc++,
Since I just have developed only one standalone project in vc++, so dont have any enterpirse development in VC++. I have been given a task to deveop an example chat software to check my picking abilities. The problem is that I will have to deveop that in 'JUST' one week using sockets and mutithreading. The software will not be very complex

So I want to know the "complete and detailed procedure" to follow for deveoping that in one week at any cost. For instance I want to know , should I create MDI or SDI or dialog based, what , what and what tools and methods will I have to use. I need complete sequence of steps to follow.

Note: I am not asking for code or project to be made by anyone else.  I must develop that.

Regards.
0
Comment
Question by:VirtualEye
8 Comments
 

Author Comment

by:VirtualEye
ID: 10764732
I also want to tell that the edition of vc++ will be 6.0 with MFC.
0
 
LVL 22

Expert Comment

by:grg99
ID: 10764888
One week is rather short deadline.  Do you know a lot about threads and socket programming? You can easily burn up a week just learning the basics of each of these subjects.

Some of the basic things you need:

Some way for each end to know about the existence of the other end, such as ask for the DNS name of the other end.

open a socket to listen for connections.

Open a connection from the other end to that socket.

Sed some sort of introductory handshake, passing info as needed, such as the name of that user,
any validations, etc.

Ask the user to type a line.

Pass back and forth the packets of text.

Display the text in a window.

... Thats basically it.


0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10766251
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 300 total points
ID: 10767893
With VC there are sample chat programs 'Chat Client' and 'Chat Server' that probably would meet your request. Writing your own program is a job that would require months if you still have to gain the basics.

If you couldn't get/use these samples, you may go on like this:

1. Create a dialog-based MFC application - using Application Wizard - and call it Chat.
2. Change Settings-C++-Code-Generation to Multithreaded-Debugging /Win32 Debug)
    resp. MultiThreaded (Win32 Release)
3. Add Wsock32.lib to Settings-LINK-Input-Object/Library Modules
4. Design a Chat Dialog using the Resource Editor where you have two multi-line Edit Fields,
    one to show messages you got and one to edit your own messages.
5. Make both fields vertical scrolling and check 'Want Return" option. First field should be read-only.
6. Create member variables for both edit fields.
7. Create two threads using beginthread(...) in CChatDlg::OnInitDialog
     - First uses       static void CChatDlg::ServerThread(void* pDlg) as start function
     - Second uses   static void CChatDlg::ClientThread(void* pDlg) as start function    
8. You have to declare both static member functions in your dialog class.
9. The void* argument to pass is 'this' - the dialog pointer, e. g.
    beginthread(CChatDlg::ServerThread, 0, this);
10. Implement ServerThread() by
     - including <winsock2.h>
     - create a socket
     - get a unique port number (any instance of the chat app must use an own - wellknown port no)
     - bind() port to socket
     - listen() to the socket for incoming requests
     - accept() incoming clients (you create a new socket when accepting)
     - create a new Client Thread and pass the socket via pDlg member
     - wait for new clients
11. Implement ClientThread by
     - including <winsock2.h>
     - check pDlg if there is a connected socket where to read messages from
     - if yes,
          - read messages from socket and send them to pDlg. exit thread if connection dies.
          - check pDlg if there are messages to send          
     - if no,
        - create a socket
        - try to connect to the server IP address (or name) and port different from own server
          IP and port. If success, create a new ClientThread and pass the current socket via pDlg member
        - try next known server - if any
12. Implement dialog by writing a handler for incoming messages.
      These messages get added to the first edit field.
13. Implement OnOK() by reading text from second edit field and send this text to all client threads
      that are successfully connected. Add a client name/id to each message.

Tell me, if you need further advice (or tools).

Regards, Alex


     
0
 

Author Comment

by:VirtualEye
ID: 10789472
Thanx for Response, I will try check your advices.
Regards.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now