Skip to content

an echo server example based on epoll, a scalable I/O event notification mechanism

Notifications You must be signed in to change notification settings

onestraw/epoll-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

epoll echo server example

  • epoll.c includes both server-end and client-end code.
  • please refer to epoll for details.

demo

open 4 terminals: t1, t2, t3 and t4. t1 is used for starting echo server, t2 and t3 are used for starting clients, t4 is used for monitoring the connections.

t1

root:epoll-example# ./a.out -c
input: hello world
echo: hello world
input: 

t2

root:epoll-example# ./a.out -c
input: The  epoll  API  performs  a  similar task to poll(2): monitoring multiple file descriptors to see if I/O is possible on any of them.
echo: The  epoll  API  performs  a  similar task to poll(2): monitoring multiple file descriptors to see if I/O is possible on any of them.
input: I'm geeksword, guy
echo: I'm geeksword, guy
input: 

t3

root:epoll-example# ./a.out -s
[+] connected with 127.0.0.1:40380
[+] data: hello world
[+] connected with 127.0.0.1:40383
[+] data: The  epoll  API 
[+] data:  performs  a  si
[+] data: milar task to po
[+] data: ll(2): monitorin
[+] data: g multiple file 
[+] data: descriptors to s
[+] data: ee if I/O is pos
[+] data: sible on any of 
[+] data: them.
[+] data: I'm geeksword, g
[+] data: uy

t4

root:epoll-example# netstat --inet -n |grep 8080
tcp        0      0 127.0.0.1:40383         127.0.0.1:8080          ESTABLISHED
tcp        0      0 127.0.0.1:40380         127.0.0.1:8080          ESTABLISHED
tcp        0      0 127.0.0.1:8080          127.0.0.1:40380         ESTABLISHED
tcp        0      0 127.0.0.1:8080          127.0.0.1:40383         ESTABLISHED

About

an echo server example based on epoll, a scalable I/O event notification mechanism

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages