0

I'm setting up a server with some clients using socket programming in c.

I found that in order to have more than one client, I should use threads or select or poll.

I know how should I use these function but when I searched I found that there is a way that used from thread and select together.

I have two questions:

1) what is the reason and benefits(using select and thread together)?

2) Is thread used for clients and select for reading the socket?

spring_64
  • 31
  • 5
  • There are several answers already posted on this site, as well as others, describing client/server architectures. This _[answer](https://stackoverflow.com/a/4173323/645128)_ discusses both threads and select as components of different server approaches. – ryyker Aug 01 '19 at 12:13
  • @ryyker Yes, I saw most of the posts, but they are all explain why we use select. I want to know why we use select and thread toghether. – spring_64 Aug 01 '19 at 12:13

1 Answers1

1

You can handle more than one socket/client in one thread by using select/epoll and non-blocking I/O. You can handle even more sockets/clients if you have multiple threads doing that.

Old but still relevant read The C10K problem.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271