Skip to content

Server code handling multiple connections without threads

Notifications You must be signed in to change notification settings

mbrueckner-psi/mulcons_nothreads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

mulcons_nothreads

This is a small server simulating a detector server.

This code is based on this example: [https://www.geeksforgeeks.org/socket-programming-in-cc-handling-multiple-clients-on-server-without-multi-threading/]

Compile it with

gcc -Wall server.c -o server

And run it with

./server

Then start a second and third terminal window. In the second window start

telnet localhost 8888

and type a which starts the "acquisition".

You see a countdown on the server side. The connection remains open and telnet is still running.

In the third window open another telnet session

telnet localhost 8888

and type t

This returns the "temperature" (always 50°C) while the "acquisition" is still running.

Server command list:

  • a - starts acquisition
  • s - stops the acquisition and closes the connection
  • t - returns temperature
  • x - status of acquisition

About

Server code handling multiple connections without threads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages