Solved

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

Posted on 2004-04-06
8
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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