Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am an experienced network programmer and am faced with a situation where i need some advice.

I am required to distribute some data on several outgoing interfaces (via different tcp socket connections, each corresponding to each interface). However, the important part is, i should be able to send MORE/most of the data on the interface with better bandwidth i.e. the one that can send faster.

The opinion i had was to use select api (both unix and windows) for this purpose. I have used select, poll or even epoll in the past. But it was always for READING from multiple sockets whenever data is available.

Here i intend to write successive packets on several interfaces in sequence, then monitor each of them for write descriptors (select parameter), then which ever is available (means it was able to send the packet first), i would keep sending more packets via that descriptor.

Will i be able to achieve my intension here? i.e. if i have an interface with 10Mbps link vs another one with 1Mbps, i hope to be able to get most of the packets out via the faster interface.

share|improve this question
Do you have one data source which shall be send via all the different connections, or do you have multiple sources, one per connection for example? – alk 2 hours ago
A single data source i.e. a file which i am required to divide in chunks and send across all interfaces with one fixed size chunk at a time. – fayyazkl 2 hours ago

1 Answer

I'd adapt the producer/consumer pattern. In this case one producer and several consumers.

Let the main thread handle your source (be the producer) and spawn off one thread for each connection (being the consumers).

The treads in parallel pull a chunk of the source each and send it over the connection one by one.

The thread holding the fastest connection is expected to send the most chunks in this setup.

share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.