Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
Y

yum 2010

@yum 2010
About
Posts
15
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • sever is not displaying the content that " you have left the chat room"....
    Y yum 2010

    ok i try. Thanks for immediate response. Regards.

    C# help sysadmin question lounge

  • sever is not displaying the content that " you have left the chat room"....
    Y yum 2010

    I have edited the format.... Regards.

    C# help sysadmin question lounge

  • sever is not displaying the content that " you have left the chat room"....
    Y yum 2010

    oh.. okay..

    C# help sysadmin question lounge

  • sever is not displaying the content that " you have left the chat room"....
    Y yum 2010

    OriginalGriff wrote:

    Alternatively, post a relevant code fragment here, and save us all that mental effort.

    here is the code for server.

    using System;
    using System.Threading;
    using System.Net.Sockets;
    using System.Text;
    using System.Collections;

    namespace ConsoleApplication1
    {
    class Program
    {
    public static Hashtable clientsList = new Hashtable();

        static void Main(string\[\] args)
        {
            TcpListener serverSocket = new TcpListener(6050);
            TcpClient clientSocket = default(TcpClient);
            int counter = 0;
    
            serverSocket.Start();
            Console.WriteLine("Chat Server Started ....");
            DateTime currentSystemTime = DateTime.Now;
            Console.WriteLine(currentSystemTime);
            DateTime startTime = DateTime.Now;
    
            
            counter = 0;
            while ((true))
            {
                counter += 1;
                clientSocket = serverSocket.AcceptTcpClient();
    
                byte\[\] bytesFrom = new byte\[10025\];
                string dataFromClient = null;
                string dataToClient=null;
                string temp = null; ;
                NetworkStream networkStream = clientSocket.GetStream();
                networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize);
                temp = System.Text.Encoding.ASCII.GetString(bytesFrom);
                dataToClient = temp.Substring(temp.IndexOf("$") + 1, (temp.IndexOf("%") - temp.IndexOf("$") - 1));
                dataFromClient = temp.Substring(0, temp.IndexOf("$")); 
    
                clientsList.Add(dataFromClient, clientSocket);
    
                //broadcast(dataFromClient + " Joined ", dataFromClient, false,dataToClient,dataFromClient);
    
                Console.WriteLine(dataFromClient + " Joined chat room ");
                DateTime currentSystemTime1 = DateTime.Now;
                Console.WriteLine(currentSystemTime1);
                handleClinet client = new handleClinet();
                client.startClient(clientSocket, dataFromClient, clientsList);
         
        }
            //clientSocket.Close();
            //serverSocket.Stop();
            //Console.WriteLine("exit");
            //DateTime stopTime = DateTime.Now;
            //Console.WriteLine(stopTime);
            /\* Compute the duration between the initial and the end time. \*/
            //TimeSpan duration = stopTime - startT
    
    C# help sysadmin question lounge

  • sever is not displaying the content that " you have left the chat room"....
    Y yum 2010

    Hi everyone, I have a server-client chat application.The server program is running successfully but when the client press the button of disconnect,it doesn't display the line " you have left the session/chat room". Although it displays on Client window but i want to display this on server as well. Kindly giuide me how can i fix this problem. Best Regards.

    C# help sysadmin question lounge

  • C# . net to perl converter?? ??
    Y yum 2010

    Can anyone tell me about a converter that can convert a C# code (written using visual studio.net)to Perl script.. i have searched a lot on internet but couldn't find any information. kindly tell me if anyone knows about such converter. Regards

    C# csharp perl visual-studio tools question

  • Need Help in multithread C# socket programming!!!
    Y yum 2010

    Eddy Vluggen wrote:

    I can't. The code that you posted is a basic client/server example. I suggest you search for multiple chat-applications and study them.

    okay!

    C# csharp sysadmin help

  • Need Help in multithread C# socket programming!!!
    Y yum 2010

    Eddy Vluggen wrote:

    I guess you can adapt it to send a message on every keystroke.

    hey can yu guide me that how can i do this?? :(

    C# csharp sysadmin help

  • Need Help in multithread C# socket programming!!!
    Y yum 2010

    Eddy Vluggen wrote:

    You mean when you press "A", that the other side immediately receives that character and displays it?

    yeah!!

    C# csharp sysadmin help

  • Need Help in multithread C# socket programming!!!
    Y yum 2010

    Hi everyone! when i run the programs of server and client, they both run and also show the acknowledgement like >>Server Started! >>Client No:1 started! >>From client-1Message from Client >>Server to client<1>1 and so on for client 2, 3 ... but i want communication like if i type some text and then it display that text!!! I am using visual 2010... multithread Server program is

    using System;
    using System.Threading;
    using System.Net.Sockets;
    using System.Text;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    TcpListener serverSocket = new TcpListener(8888);
    TcpClient clientSocket = default(TcpClient);
    int counter = 0;

    serverSocket.Start();
    Console.WriteLine(" >> " + "Server Started");

    counter = 0;
    while (true)
    {
    counter += 1;
    clientSocket = serverSocket.AcceptTcpClient();
    Console.WriteLine(" >> " + "Client No:" + Convert.ToString(counter) + " started!");
    handleClinet client = new handleClinet();
    client.startClient(clientSocket, Convert.ToString(counter));
    }

    clientSocket.Close();
    serverSocket.Stop();
    Console.WriteLine(" >> " + "exit");
    Console.ReadLine();
    }
    }

    //Class to handle each client request separatly
    public class handleClinet
    {
    TcpClient clientSocket;
    string clNo;
    public void startClient(TcpClient inClientSocket, string clineNo)
    {
    this.clientSocket = inClientSocket;
    this.clNo = clineNo;
    Thread ctThread = new Thread(doChat);
    ctThread.Start();
    }
    private void doChat()
    {
    int requestCount = 0;
    byte[] bytesFrom = new byte[10025];
    string dataFromClient = null;
    Byte[] sendBytes = null;
    string serverResponse = null;
    string rCount = null;
    requestCount = 0;

    while ((true))
    {
    try
    {
    requestCount = requestCount + 1;
    NetworkStream networkStream = clientSocket.GetStream();
    networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize);
    dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom);
    dataFromClient = dataFromClient.Substring(0, dataFromClient.IndexOf("$"));
    Console.WriteLine(" >> " + "From client-" + clNo + dataFromClient);

    rCount = Convert.ToString(requestCount);
    serverResponse = "Server to clinet(" + clNo + ") " + rCount;
    sendBytes = Encoding.ASCII.GetBytes(serverResponse);
    networkStream.Write(sendBytes, 0, sendBytes.Length);
    networkStream.Flush();
    Console.WriteLine(" >> " + serverResponse);
    }
    catch (Exception ex)
    {
    Console.WriteLine(" >> " + ex.ToString());
    }
    }
    }
    }
    }

    the Clie

    C# csharp sysadmin help

  • Click here to send data to sever!! [modified]
    Y yum 2010

    I have edited my post!!

    C# csharp question visual-studio sysadmin tutorial

  • Click here to send data to sever!! [modified]
    Y yum 2010

    hello everyone, how can i send data to server?? I am using visual studio 2010.The program is working but i am not getting the option of " click here to send data to server" in the Form1 window that comes after client-server acknowledgment.Kindly guide me. client program is

    using System;
    using System.Windows.Forms;
    using System.Net.Sockets;
    using System.Text;

    namespace WindowsApplication1
    {
    public partial class Form1 : Form
    {
    System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient();
    NetworkStream serverStream;

        public Form1()
        {
            InitializeComponent();
        }
    
        private void Form1\_Load(object sender, EventArgs e)
        {
            msg("Client Started");
            clientSocket.Connect("127.0.0.1", 8888);
            label1.Text = "Client Socket Program - Server Connected ...";
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            NetworkStream serverStream = clientSocket.GetStream();
            byte\[\] outStream = System.Text.Encoding.ASCII.GetBytes("Message from Client$");
            serverStream.Write(outStream, 0, outStream.Length);
            serverStream.Flush();
    
            byte\[\] inStream = new byte\[10025\];
            serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);
            string returndata = System.Text.Encoding.ASCII.GetString(inStream);
            msg("Data from Server : " + returndata);
        }
    
        public void msg(string mesg)
        {
            textBox1.Text = textBox1.Text + Environment.NewLine + " >> " + mesg;
        } 
    }
    

    }

    the server program is

    using System;
    using System.Threading;
    using System.Net.Sockets;
    using System.Text;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    TcpListener serverSocket = new TcpListener(8888);
    TcpClient clientSocket = default(TcpClient);
    int counter = 0;

            serverSocket.Start();
            Console.WriteLine(" >> " + "Server Started"); 
    
            counter = 0;
            while (true)
            {
                counter += 1;
                clientSocket = serverSocket.AcceptTcpClient();
                Console.WriteLine(" >> " + "Client No:" + Convert.ToString(counter) + " started!");
                handleClinet client = new handleC
    
    C# csharp question visual-studio sysadmin tutorial

  • to handle Multiple clients....
    Y yum 2010

    hi everyone, I have done single client-server application using c#. Now i have to made that application for multiple clients. kindly guide me. Regards

    C# csharp sysadmin tutorial

  • IAX/IAX2 protocol scripting ??
    Y yum 2010

    yeah you are right , it is AIX, someone told me wrong that it is IAX.. any ways thankyou :)

    C# question csharp sysadmin tutorial

  • IAX/IAX2 protocol scripting ??
    Y yum 2010

    Hi Everyone Can anyone tell me about IAX scripting. what is it? and can it be used in the communication of client and server? I have done the client-server programming in C#.Both the programs are running individually but how can i communicate the client with server and vice verse.I mean how the connection between them is established?? Kindly guide me.!! Regards,

    C# question csharp sysadmin tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups