Skip to content

Instantly share code, notes, and snippets.

@kkumar-fk
Created July 24, 2019 02:56
Show Gist options
  • Save kkumar-fk/d830c6c3c81d22154b327570133fc161 to your computer and use it in GitHub Desktop.
Save kkumar-fk/d830c6c3c81d22154b327570133fc161 to your computer and use it in GitHub Desktop.
Typical server program
1. Create a socket:
server_fd = socket(...);
2. Bind to a well known IP address and port#:
ret = bind(server_fd, ...);
3. Mark the socket as passive by changing it's state to LISTEN:
ret = listen(server_fd, ...);
4. Wait for a client to connect, and get a reference file descriptor:
client_fd = accept(server_fd, ...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment