基本步骤如下
server client
+++++++ ++++++++
创建socket 创建socket
+++++++ ++++++++
| |
| |
| |
+++++++ ++++++++
地址赋值( 地址赋值(
自己的地址) 服务器地址)
+++++++ ++++++++
| |
| |
| |
++++++++ |
用bind绑定 |
socket和地址 |
++++++++ |
| |
| |
| |
+++++++ |
listen |
+++++++ |
| ++++++++++
| <------------------------------ connect 服务器
| ++++++++++
+++++++ |
accept |
+++++++ |
| |
| +++++++++
| recv 和send
| 进行数据处理
| +++++++++
+++++++++ |
用accept得到 |
的socket进行 |
recv 和 send |
+++++++++ |
| |
| |
| |
+++++++++ +++++++++
close socket close socket
+++++++++ +++++++++