Results 1 to 2 of 2

Thread: Winsock Server with multiple simultaneous clients

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Winsock Server with multiple simultaneous clients

    So, I'm trying to develop a server application that uses Winsock to connect out to 10 clients at the same time. Once connected I want to transfer large files, somewhere on the order of 100MB to all 10 clients at the same time.

    I have an array of 10 sockets that connect out. Once the connection is made in the Socket_Connect(Index As Integer) event I can begin transferring the file.

    My question is, while the 100MB transfer with one client is taking place will the Socket_Connect event still fire when it connects to another client, or since VB is single threaded will the thread just sit there transferring the file to the first client and queue the other client(s)?

    My explanation is kind of confusing but I did my best to make it readable.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Winsock Server with multiple simultaneous clients

    Yes, VB is single-threaded, but it still can send to multiple cliets because the winsock control is multithreaded.

    Let me explain:
    Lets say all connection speeds are 10 KBytes/Second, first client connects, you send a 100K packet to that cliet, so this means that it taks 10 seconds to send (10K/Sec, 100K to send), so, you call Winsock1.SendData once, and it takes 10 seconds to actually send the data... what do you do in the mean time ? you send data to the other clients. And for the other clients, is the same thing... you winsock1.SendData, and wait until it's sent...

    Take a look at the client/server I made here:
    http://www.vbforums.com/showthread.php?t=377648
    It is the reverse of what you are planning to do... the client(s) send data to the server, but take a look at how the client sends data to the server, you have to do the same for your program.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width