Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - watarok

Pages: [1]
1
Network / Match user's TCP sending speed
« on: July 30, 2014, 04:11:36 am »
I wish to send some arbitrary amount of data across a TCP connection. I expect that there will be a problem wherein the size of the chunks of data will be too large or the frequency at which they're sent will be too great, resulting in a backup of data being sent.

For example (pseudo):
sf::TcpSocket socket;
// connect socket
while(!endOfData) {
    socket.send(/*a chunk of data*/);
    // get next chunk of data
}
 

Now if data is being queued for sending faster than the socket can actually send it off, there will be a backlog of data that hasn't really been sent. I therefore want to reduce the speed at which it is sent.

My solution:
sf::TcpSocket socket;
// connect socket
while(!endOfData) {
    sf::Socket::Status status = sf::Socket::NotReady;
    while(status == sf::Socket::NotReady) {
        status = socket.send(/*a chunk of data*/);
    }
    // get next chunk of data
}
 

This now tries to send the same data until the status returned isn't sf::Socket::NotReady. This seems like the logical solution, but I'm not sure that this is the actual status returned in this situation (when the socket's buffer isn't empty).

How can I regulate the sending speed of a TcpSocket to match the user's system? Furthermore, is it also possible/recommended to match the receiver's download speed as well?



PS: The examples above are not meant as actual implementations, but rather only serve to demonstrate the problem.

2
Network / Linking clients and servers on a local network
« on: March 30, 2014, 08:55:35 am »
I have a system where clients are meant to connect to a server located on the LAN. It seems unreasonable for users to have to enter the address and port of a server, so I was planning on using broadcasting. The problem I'm facing is how it's possible to make all clients aware of all available servers.

As far as I'm aware, broadcasting only sends to a specific port on each computer. This seems to mean that either all of the clients or all of the servers need to have a common port number. Logically, there would be less servers, and it's more likely that they'll be able to bind to a shared port. This is still unreliable and limits each computer to a single server. Is there a better solution that I'm missing?

Pages: [1]
anything