Example #1
0
 def __init__(self, ip, sock, byte_size):
     Thread.__init__(self)
     self.ip = ip
     self.socket = sock
     self.byte_size = byte_size
     self.checksum = 0
     self.field = 21845
     self.msg_pack_format = "!iHH" + str(byte_size) + "s"
     self.msg_ack_unpack_format = "!iHH"
     self.send_byte = {}
     self.packet = create_packet()
     self.lock = Lock()
Example #2
0
import random
import socket
from create_packet import create_packet

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_3 = ('localhost', 7755)
s.bind(server_3)
msg = "ok"
reply = msg.encode('utf-8')
recv_seq_num = []
ack_format = "!iHH"
packet = create_packet()


def get_byte_size(reply):
    byte_size, client = s.recvfrom(1024)
    real_byte_size = byte_size.decode('utf-8')
    s.sendto(reply, client)
    format_for_packet = "!iHH" + real_byte_size + 's'
    return format_for_packet


unpack_format = get_byte_size(reply)

with open('server_3.txt', 'w') as f:
    while True:
        data, client = s.recvfrom(1024)
        if not data:
            s.sendto(reply, client)
            f.close()
            break
Example #3
0
def real_packet():
	return cp.create_packet("00:00:00:00:00","Python_server","Prime","1","NULL",90001,99999)
Example #4
0
def first_packet():
	return cp.create_packet("00:00:00:00:00","Python_server","Prime","1","NULL",100,90000)
Example #5
0
def real_packet():
    return cp.create_packet("00:00:00:00:00", "Python_server", "Prime", "1",
                            "NULL", 90001, 99999)
Example #6
0
def first_packet():
    return cp.create_packet("00:00:00:00:00", "Python_server", "Prime", "1",
                            "NULL", 100, 90000)