C# .NET - how to develop like YahooMessenger chat application using c#?or which .Net Tech is better?

Asked By prabhakar kamcharla on 15-Jun-12 08:58 AM
Hi All,

Good Evening.
i want to develop like YahooMessenger Chat Application,any one can help me out,pls dont unnecessary websites?
Thanks in Advance.
Jitendra Faye replied to prabhakar kamcharla on 15-Jun-12 09:20 AM

For implement chating you can use third party plugin.
follow this link-


http://www.envolve.com/blog/2011/02/new-ruby-api-library-add-chat-to-your-rails-app/

here you will get plugin for chating.

by using code follow this link-
http://www.codeproject.com/KB/IP/TCPIPChat.aspx


 
I hope this will help you.

Peter Bromberg replied to prabhakar kamcharla on 15-Jun-12 08:17 PM
There are a number of chat-type applications on codeplex.com complete with source code.
dipa ahuja replied to prabhakar kamcharla on 16-Jun-12 05:39 PM
The .NET Framework provides us with a higher level of abstraction upon sockets in the form of TcpListener and TcpClient. TcpListener is a high level interface for server and TCPClient is for client application.
It will use two namespaces System.Net and System.Net.Sockets which are required for Socket Programming. Basically, TCPListener class provides simple methods to listen and accepts incoming connection requests whereas, TcpClient class implements a socket for sending and receiving data using TCP.
Server
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
 
namespace TcpServer
{
    class ServerClass
    {
      
        static void Main(string[] args)
        {
            IPAddress IP = IPAddress.Parse("127.0.0.1"); 

// Local address to listen.
            TcpListener Listener = new TcpListener(IP, 1986); 
// Listening from TCP clients.
            Listener.Start(); // Starts listening for incoming requests.
            Console.WriteLine("Server is up at port 1986");
            Console.WriteLine("Waiting for the connection...");
            ClientClass user = new ClientClass(Listener.AcceptTcpClient());
    
            string Message = Console.ReadLine();
            user.SendMessage(Message);
 
        }
    }
 
    class ClientClass
    {
        TcpClient Client;
        byte[] Data;
        bool Flag = true;
        NetworkStream netStream;
 
        // When a client comes in.
        public ClientClass(TcpClient newClient)
        {
            Client = newClient;
 
            Console.WriteLine("Connected with " + Client.Client.RemoteEndPoint);
 
            // To notify the client about his connection.
            SendMessage("Connected.");
 
            // For receiving the data.       
            Data = new byte[100];
            netStream = Client.GetStream();
            netStream.BeginRead(Data, 0, 100, ReceiveMessage, null);
        }
 
        // Read from clients.
        public void ReceiveMessage(IAsyncResult ar)
        {
            int bufferLength;
            try
            {
                bufferLength = Client.GetStream().EndRead(ar);
 
                // Receive the message from client side.
                string messageReceived = Encoding.ASCII.GetString(Data, 0,
 bufferLength);
 
                // Display it on server's console.
                Console.WriteLine(Client.Client.RemoteEndPoint.ToString() + "-> "

 + messageReceived);
 
                // Continue reading from client. 
                Client.GetStream().BeginRead(Data, 0, 100, ReceiveMessage, null);
            }
            catch(Exception ex)
            {
                Console.WriteLine(Client.Client.RemoteEndPoint.ToString() + " 
is disconnected.");
            }
        }
 
        // Send the message.
        public void SendMessage(string message)
        {
            try
            {
                byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message);
                Client.Client.Send(bytesToSend);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
}
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=69