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
  1. Home
  2. General Programming
  3. C#
  4. problem with client/server application

problem with client/server application

Scheduled Pinned Locked Moved C#
helpsysadmintutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ajithevn
    wrote on last edited by
    #1

    how to send the message sent from one client to another client, plz help me.

    C S 2 Replies Last reply
    0
    • A Ajithevn

      how to send the message sent from one client to another client, plz help me.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      By writing code. Perhaps you need to ask something more specific ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      A 1 Reply Last reply
      0
      • A Ajithevn

        how to send the message sent from one client to another client, plz help me.

        S Offline
        S Offline
        spiritboy
        wrote on last edited by
        #3

        Try creating a TcpListener , listening at a local endpoint and accepting tcp connections TcpListener listener = new TcpListener(YOUR EndPoint here(new LocalEndPoint(....))); listener.Start(); Listener.AcceptTcpConnections... //Wait for new Connection from Client Then at the Client Side you should simply create a TcpClient and connect To a RemoteEndPoint which is what u've created as localEndpoint at your server side, TcpClient tcpc = new TcpClient(remoteEndPoint); then you can send objects to server and obtain responses try http://www.google.com/search?hl=en&source=hp&q=simple+Client+Server+C%23&aq=f&oq=&aqi=

        1 Reply Last reply
        0
        • C Christian Graus

          By writing code. Perhaps you need to ask something more specific ?

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          A Offline
          A Offline
          Ajithevn
          wrote on last edited by
          #4

          there are 2 systems with ips 192.168.1.87(clientA,serverA) and 192.168.1.35(clientB,serverB) . on both the systems client and server runs. now clientA sends a message to serverB on button click. as soon as serverB recieves a message it should send that message to ClientB how is that possible clientA--->serverB(onmessagerecieved)--->cientB

          server:-
          int recv;
          byte[] data = new byte[1024];
          IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 10294);
          Socket newsock = new Socket(AddressFamily.InterNetwork,
          SocketType.Dgram, ProtocolType.Udp);
          newsock.Bind(ipep);
          newsock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Any, IPAddress.Parse("127.0.0.1")));

          while (true)
          {
          IPEndPoint sender2 = new IPEndPoint(IPAddress.Any, 0);
          IPEndPoint sender1 = new IPEndPoint(IPAddress.Parse("192.168.1.35") , 0);
          EndPoint tmpRemote = (EndPoint)(sender2);
          EndPoint tmpRemote1 = (EndPoint)(sender1);
          data = new byte[1024];
          recv = newsock.ReceiveFrom(data, ref tmpRemote);
          Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
          string welcome = "7010";
          data = Encoding.ASCII.GetBytes(welcome);
          newsock.SendTo(data, data.Length, SocketFlags.None, tmpRemote1 );
          }

          client:-
          IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.1.35"), 10294);
          byte[] data = new byte[1024];
          Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

          private void Form1_Load(object sender, EventArgs e)
          {
          client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10);
          }
          private void button1_Click(object sender, EventArgs e)
          {
          string welcome = "What's your IP?";
          data = Encoding.ASCII.GetBytes(welcome);
          client.SendTo(data, data.Length, SocketFlags.None, ipep);
          }

          private void timer1_Tick(object sender, EventArgs e)
          {
          IPEndPoint server = new IPEndPoint(IPAddress.Any, 0);
          EndPoint tmpRemote = (EndPoint)server;
          data = new byte[1024];
          int recv = client.ReceiveFrom(data, ref tmpRemote);
          this.richTextBox1.Text = Encoding.ASCII.GetString(data, 0, recv);
          }

          private void Form1_FormClosing(object sender, FormClosingEventArgs e)
          {
          client.Close();
          }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

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