0

I have a server and a client component, both written in C. The servers saves the socket file descriptor into an integer variable - this is used later for closing the socket.

The server will have quite a few connections open at the same time and I would like to keep track of the socket file descriptors. The concept of linked and double linked lists is not new to me and I have already implemented it a few times. However, I have recently stumbled across a question here and now I am not sure if a linked list is the best way to go. Does this "dynamic" array have any downsides compared to the linked lists? When would I be using the "dynamic" array and when to use a linked list?

EDIT: To clarify - With "quite a few connections" I meant up to 100 simultaneous connections.

Aginu
  • 156
  • 2
  • 17
  • 1
    What is "quite a few" ? Dozends? Hundreds? Thousands? – Jabberwocky May 01 '20 at 12:26
  • 3
    if you always add/remove elements at the end of the list a dynamic array is faster and use less memory. If you add/remove elements elsewhere using an array you have to move elements which is expensive – bruno May 01 '20 at 12:26
  • If the number of connections is **maximum** hundred, then arrays can help, **but really, it depends on your use case**. – kiner_shah May 01 '20 at 12:31

0 Answers0