Beispiel #1
0
* 处理业务逻辑
* 多进程并发模型
"""

from socket import *
from multiprocessing import Process
import signal, sys
from time import sleep

from dict_db import User

HOST = '0.0.0.0'
PORT = 3235
ADDR = (HOST, PORT)
db = User(database='dict')  # 数据库操作对象


# 注册逻辑
def do_register(connfd, data):
    tmp = data.split(' ')
    name = tmp[1]
    passwd = tmp[2]
    if db.register(name, passwd):
        connfd.send(b'OK')
    else:
        connfd.send(b'Fail')


#登录逻辑
def do_login(connfd, data):
Beispiel #2
0
import sys

from socket import *
from multiprocessing import Process

from dict_db import User

ADDR = ('0.0.0.0', 12345)
q = User("dict")


class DictServer:
    def __init__(self):
        pass

    def zhuce(self, c, name, password):
        print('l')
        if q.register(name, password):
            c.send(b"OK")
        else:
            c.send(b"f")

    def denglu(self, c, name, password):
        if q.login(name, password):
            c.send(b"OK")
        else:
            c.send(b"f")

    def do_query(self, c, name, word):
        a = q.query(word)
        if a:
Beispiel #3
0
dict 服务端

* 处理业务逻辑
* 多进程并发模型
"""
from multiprocessing import Process
from socket import *
import signal, sys
from time import sleep

from dict_db import User

HOST = '0.0.0.0'
PORT = 4321
ADDR = (HOST, PORT)
db = User(database='dict')


def do_register(connfd, data):
    tmp = data.split(' ')
    name = tmp[1]
    password = tmp[2]
    if db.register(name, password):
        connfd.send(b'OK')
    else:
        connfd.send(b'Fail')


def do_login(connfd, data):
    tmp = data.split(' ')
    name = tmp[1]
Beispiel #4
0
                    new_passwd = hash.hexdigest() # 得到转换后的密码
                        
     """

from dict_db import User
from socket import *
from multiprocessing import Process
import signal, sys
from time import sleep

# 处理僵尸进程
signal.signal(signal.SIGCHLD, signal.SIG_IGN)

# 地址
ADDR = ('0.0.0.0', 8888)
db = User('dict')


# 注册
def do_register(connfd, data):
    tmp = data.split(' ')
    name = tmp[1]
    passwd = tmp[2]
    if db.register(name, passwd):
        connfd.send(b'ok')
    else:
        connfd.send(b'fail')


# 登录
def do_enter(connfd, data):