1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python客户端与服务器端通信_python客户端与服务器端的通信

python客户端与服务器端通信_python客户端与服务器端的通信

时间:2020-06-25 15:23:11

相关推荐

python客户端与服务器端通信_python客户端与服务器端的通信

服务器端: import java.io.*;import .*;public class xin {ServerSocket mSS;Socket mSocket;static int port;public xin(){try{mSS = new ServerSocket(port);System.out.println("涂涂说创建了一个Server");System.

Server.py: '''

Created on 3月7日

@author: pangbin2415

'''import socketsock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # 生成socket对象sock.bind(('localhost', 8001))

#绑定主机ip和端口号sock.listen(5)while True:

connection,addr = sock.accept()

#接受客户端的连接

try:

connection.settimeout(5)

buf = connection.recv(1024)

if buf == 1:

connection.s/*使用Socket 通信实现 FTP 服务器端 程序*/#include "unp.h"#include #define SA

struct sockaddrint main(int argc, char *argv[]){

int

sock_fd, new_fd;

struct sockaddr_in

server_addr, client_addr;

intend('welcome to server!')

#向客户端发送一个字符串信息

else:

connection.send("Failed")

except socket.timeout:

#如果出现超时

print 'time out'

connection.close() Client.py '''Created on 3月7日@author: pangbin2415'''import socketimport timesock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.connect(('localhost', 8001))time.sleep(2)sock.send('1')print sock.recv(1024)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。