Solved

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

Posted on 2004-04-06
8
172 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Getting IP address 8 122
Least Squares Curve Fitting 4 133
How to print into std::string like sprintf using C++11? 12 181
Where are the c++ header files to use in Eclipse? 4 73
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 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