send and recieve message with myself (python socket )
# socket server
import socket
sk = socket.socket()
sk.bind(("127.0.0.1",8082))
sk.listen()
conn, addr = sk.accept()
message = conn.recv(1024)
print(message)
conn.send(b"hello, world")
conn.close()
sk.close() #socket client
import socket
sk = socket.socket()
sk.connect(("127.0.0.1",8082))
sk.send(b"hello you ")
message = sk.recv(1024)
print(message)
sk.close()
sorry about having no annotation for every code
if we run the programme in one IDLE, we will have error such as ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
so i seek help on internet , the solution of the problem is to open two IDLE , and the problem will be solved.
send and recieve message with myself (python socket )的更多相关文章
- python socket编程入门(编写server实例)+send 与sendall的区别与使用方法
python 编写server的步骤: 1. 第一步是创建socket对象.调用socket构造函数.如: socket = socket.socket( family, type ) family参 ...
- Python Socket 编程——聊天室示例程序
上一篇 我们学习了简单的 Python TCP Socket 编程,通过分别写服务端和客户端的代码了解基本的 Python Socket 编程模型.本文再通过一个例子来加强一下对 Socket 编程的 ...
- Python Socket 网络编程
Socket 是进程间通信的一种方式,它与其他进程间通信的一个主要不同是:它能实现不同主机间的进程间通信,我们网络上各种各样的服务大多都是基于 Socket 来完成通信的,例如我们每天浏览网页.QQ ...
- Python socket编程之二:【struct.pack】&【struct.unpack】
import struct """通过 socket 的 send 和 recv 只能传输 str 格式的数据""" "" ...
- Python Socket,How to Create Socket Server? - 网络编程实例
文章出自:Python socket – network programming tutorial by Silver Moon 原创译文,如有版权问题请联系删除. Network programin ...
- Python Socket,How to Create Socket Cilent? - 网络编程实例
文章出自:Python socket – network programming tutorial by Silver Moon 原创译文,如有版权问题请联系删除. Network programin ...
- python socket编程---从使用Python开发一个Socket示例说到开发者的思维和习惯问题
今天主要说的是一个开发者的思维和习惯问题. 思维包括编程的思维和解决一个具体问题的分析思维,分析思路,分析方法,甚至是分析工具. 无论是好习惯还是不好的习惯,都是在者一天一天的思维中形成的.那些不好的 ...
- python socket编程 实现简单p2p聊天程序
目标是写一个python的p2p聊天的项目,这里先说一下python socket的基础课程 一.Python Socket 基础课程 Socket就是套接字,作为BSD UNIX的进程通信机制,取后 ...
- Python socket – network programming tutorial
原文:https://www.binarytides.com/python-socket-programming-tutorial/ --------------------------------- ...
随机推荐
- Windows搭建IIS服务器使用NATAPP实现内网穿透
目的:外网可以访问本地网页. 步骤: 一.实现内网访问 1.Win+Q搜索[控制面板],选择[程序],点击[启用或关闭Windows功能], 2.勾选[Internet Information Ser ...
- 2020.2.22 bzoj5336 party
#include<iostream> #include<cstdio> #include<cstring> #include<cctype> #incl ...
- iptables之路由网关共享上网/端口映射
linux-A 主机配置eth0即可: [root@linux-A ~]# ifconfig eth0|sed -n '2p' inet addr:192.168.20.3 Bcast:192.168 ...
- 杭电-------2053Switch Game(C语言)
/* 题目大意是指:有n个灯泡,按1-n编号,要操作n次,第i次操作是将标号是i的倍数的变成相反状态.最终求得是n次操作后,编号为n的灯泡的状态,其实就是求n的约束有多少个,及灯泡n被操作了多少次*/ ...
- 【转载】Linux进程间通信(六):共享内存 shmget()、shmat()、shmdt()、shmctl()
来源:https://www.cnblogs.com/52php/p/5861372.html 下面将讲解进程间通信的另一种方式,使用共享内存. 一.什么是共享内存 顾名思义,共享内存就是允许两个不相 ...
- 使用Vue.prototype在vue中注册和使用全局变量
在main.js中添加一个变量到Vue.prototype Vue.prototype.$appName = 'My App' 这样 $appName 就在所有的 Vue 实例中可用了,甚至在实例被创 ...
- python之基础中的基础(二)
1.字典 创建字典,alien_0={'color':'green','points':5}其中由一个又一个的“键-值”对组成. 访问键-值对相应的值,print(alien_0['color']), ...
- 如何在命令行添加换行符到git commit -m "xxx"
需求来源: 需要将自动识别的组件信息.更新信息.任务跟踪单号.下载链接等信息自动提交并推送至gerrit, 然后作为触发条件启动另一个协作业务流程. 方法1:单引号开放方法 git commit -m ...
- 1994_An Algorithm To Reconstruct Wideband Speech From Narrowband Speech Based On Codebook Mapping
论文地址:基于码本映射的窄带语音宽带重建算法 博客作者:凌逆战 博客地址:https://www.cnblogs.com/LXP-Never/p/12144324.html 摘要 本文提出了一种从窄带 ...
- NIO、多路复用的终极奥义
1.现在要让有限的系统资源发挥更大的效率,一个最直接的方式就是进行资源复用,比如线程资源复用. 2.线程资源复用的一个最有效的方式就是使用事件驱动模型进行异步调用. 3.Reactor模型就是基于事件 ...