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. Send Different Files to Different Clients at Same time

Send Different Files to Different Clients at Same time

Scheduled Pinned Locked Moved C#
sysadmin
3 Posts 2 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.
  • D Offline
    D Offline
    DeepOceans
    wrote on last edited by
    #1

    Hi I want to send different files to different clients but at same time from server. I've successfully sent a file to a single client and then to multiclients but at different times using threads. As when server is sending a file to one client and during that transmission if another clients requests for a file then 1st transmission stops and 2nd one also gets prob. so plz try to tell ASAP the appropriate solution for this. Regards.

    Shanzay

    R 1 Reply Last reply
    0
    • D DeepOceans

      Hi I want to send different files to different clients but at same time from server. I've successfully sent a file to a single client and then to multiclients but at different times using threads. As when server is sending a file to one client and during that transmission if another clients requests for a file then 1st transmission stops and 2nd one also gets prob. so plz try to tell ASAP the appropriate solution for this. Regards.

      Shanzay

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      How are you "sending" files? How does a client "request" transmission of a file? A WCF service is one way to easily solve this problem. /ravi

      This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      D 1 Reply Last reply
      0
      • R Ravi Bhavnani

        How are you "sending" files? How does a client "request" transmission of a file? A WCF service is one way to easily solve this problem. /ravi

        This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        D Offline
        D Offline
        DeepOceans
        wrote on last edited by
        #3

        I used UDP protocol for sending Video files and by using streaming I m sending.At first Server Rcv one message for sending files then send file,the Code for sending file is as following using threads. private void liveVideoToolStripMenuItem_Click(object sender, EventArgs e) { try { Control.CheckForIllegalCrossThreadCalls = false; thvideo = new Thread(new ThreadStart(transmitVideo)); thvideo.IsBackground = true; thvideo.Start(); } catch (ThreadStartException thre) { MessageBox.Show(thre.Message); } } void transmitVideo() { /////////////////////////////////UDP //////////////////////////*/ filesndsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); ipd = new IPEndPoint(IPAddress.Any, 7090); filesndsock.Bind(ipd); MulticastOption moi = new MulticastOption(IPAddress.Parse("224.0.0.1")); filesndsock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, moi); ipep = (EndPoint)ipd; while (true) { try { filesndsock.ReceiveFrom(rcvbuf, ref ipep); // Encoding and Viewing The Received Message msg = Encoding.ASCII.GetString(rcvbuf); //Server here receive msg from client for sending file MessageBox.Show(msg); try { thvideofile = new Thread(new ThreadStart(sendfile)); thvideofile.IsBackground = true; thvideofile.Start(); } catch (ThreadStartException thre) { MessageBox.Show(thre.Message); } } catch (Exception ee) { MessageBox.Show(this, ee.Message, "Unknown Exception"); } } } void sendfile() { if (dlgOpen.ShowDialog() == DialogResult.OK) { // create the raw streams inStream = File.OpenRead(dlgOpen.FileName); bufInStream = new BufferedStream(inStream); int bytesRead = 0; while ((bytesRead = bufInStream.Read(buf, 0, 16384)) > 0) { Thread.Sleep(20); filesndsock.SendTo(buf, bytesRead, SocketFlags.None, ipep); } } MessageBox.Show("File is completely transfered"); bufInStream.Close(); inStream.Close(); } But for sending same time to

        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