zoukankan      html  css  js  c++  java
  • Python sockset 套接字

    什么是Python socket

    Socket网络编程

    socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求。

    socket起源于Unix,而Unix/Linux基本哲学之一就是“一切皆文件”,对于文件用打开、读写、关闭模式来操作。socket就是该模式的一个实现,socket即是一种特殊的文件,一些socket函数就是对其进行的操作(读/写IO、打开、关闭)

    socket和file的区别:

    file模块是针对某个指定文件进行打开、读写、关闭

    socket模块是针对 服务器端 和 客户端Socket 进行打开、读写、关闭

    Socket的英文原义是“孔”或“插座”。Socket正如其英文原意那样,像一个多孔插座。一台主机犹如布满各种插座的房间,每个插座有一个编号,有的插座提供220伏交流电, 有的提供110伏交流电,有的则提供有线电视节目。 客户软件将插头插到不同编号的插座,就可以得到不同的服务。

    我知道上面那段话很枯燥,那就忘记吧!我们只需要记得:两个程序通过“网络”交互数据就使用socket,它只负责两件事:建立连接,传递数据。不能再简练了!!!

    一个完整的socket通信流程大致如下图所示

    socket函数方法

  • 相关阅读:
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
  • 原文地址:https://www.cnblogs.com/Mindstu/p/6682856.html
Copyright © 2011-2022 走看看