61

Socket封装之聊天程序(一)-SherryX-51CTO博客

 6 years ago
source link: http://blog.51cto.com/13097817/2066426
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  之前使用IPC编写过聊天程序,但是这样仅能在同一台计算机上进行聊天;要使得在不同的计算机(不同的IP+端口)上也能进行通信,就需要用到socket编程。前面说到,要处理多客户端的响应问题,需要I/O复用,即调用select或者epoll。通常我们使用epoll函数,以下例子也是。  接下来,我们需要封装一个地址类。为什么要封装这样一个类呢? &

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK