- 在线时间
- 481 小时
- 最后登录
- 2026-8-25
- 注册时间
- 2023-7-11
- 听众数
- 4
- 收听数
- 0
- 能力
- 0 分
- 体力
- 7859 点
- 威望
- 0 点
- 阅读权限
- 255
- 积分
- 2946
- 相册
- 0
- 日志
- 0
- 记录
- 0
- 帖子
- 1177
- 主题
- 1192
- 精华
- 0
- 分享
- 0
- 好友
- 1
该用户从未签到
 |
# -*- coding: utf-8 -*-& K/ n: v) x8 u
import socket
) ^- m/ i7 m" P/ k' W! u# U9 S6 ofrom myutil import *5 ~+ J2 s) M9 L* O9 I
from binascii import unhexlify as unhex
$ s! c1 t. ]2 L/ X0 ofrom ctypes import *# G) ^ {* T8 i, S7 R5 r2 N
dll = cdll.LoadLibrary('mydll.dll'). B$ n K( I+ Q* d& P7 {1 k9 Y
print 'begin load mydll..'
2 o" f1 ?6 B( jHOST, PORT = "192.168.51.28", 5800
7 F' z) K: \1 zsd ="1234567812345678"& @7 n" `0 Z1 i, c9 K1 K, }- b
# Create a socket (SOCK_STREAM means a TCP socket), e* ]# W+ A% b3 S, L) {
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)1 q0 l' ]' K' m/ u9 \
try:
5 `: z1 n, p; _8 m/ }4 L, {8 } # Connect to server and send data% w5 C5 Q z. o$ s4 F3 [
sock.connect((HOST, int(PORT))
6 W, f! G4 ^% F* q print "Sent1 OK:"7 I3 `+ [: ~9 `2 q
print sd
1 Y7 `. z# N4 I, k" J& n. @5 k # Receive data from the server and shut down6 u/ @, g; N4 r
received = sock.recv(1024)
1 F& l6 U# }; I3 a. V/ \6 J print "Received:"
$ i5 U- g9 W4 @' I/ m) U3 [& E print_hex(received)( ]2 [9 {9 I0 R* ?8 ]8 p
print 'received len is 0x%02x' %(len(received))
% [! n- L: s9 B8 x2 F print 'received data analysis...'
: ?+ _( U9 i( }5 D1 Y* d- |% R5 \# V re1=received[0:4]" R# O) }* E" I6 @7 r
print_hex(re1)
5 e8 Y7 w# C# I5 h- G re1=received[4:6]* |, x4 t! f+ V
print_hex(re1)
- [; R( g8 a, x7 O+ _ re1=received[6:10]
. M" f) k; K5 T& }$ ~1 Q g print_hex(re1)
+ a: g3 h; @5 t7 z$ Z) h5 I re1=received[10:16]
) b# M9 C6 ?" f8 O print_hex(re1)* K1 L; [$ J% a" _, Z
- g2 n: [* ]9 @! r- `! b, U
#pack2 send' b6 B+ i. d# y2 O$ {$ U
sock.send(sd2.decode('hex'))" l7 L# Z0 J1 s+ h e8 D( W, j
print "Sent2 OK:"
7 `$ K% b4 L- B8 s9 C! k' _ print sd2* u' j6 `! x( N5 C! Y$ e# k6 ?
# Receive data from the server and shut down% u+ U; Z; [5 w! W) t
received1 = sock.recv(1024)
2 m! a: r. j2 y b& w0 y- ` print "Received1:"
& ~6 F: u8 {2 \7 _9 N print_hex(received1)) F |2 [- o8 i+ G
print 'received1 len is 0x%02x' %(len(received1))# E' q" @/ U' t$ f
8 w+ F9 \; g6 g& G& H% p- t
finally:
( d4 M$ ]3 N/ x sock.close()
* ]$ I# ]! w' g8 R; ]( e5 {+ ]6 _
8 ]) u! t+ |3 S! | b, is=raw_input('press any key to continue...')" a( C* [' l2 ~( m0 ?
8 ^ c& {9 L1 Y3 N, V0 @
A" h, ~, O/ p' J |
zan
|