mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 17:03:23 +00:00
Implement vsock driver
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
39c2e17f75
commit
52f808e315
22
test_vsock/vsock_server.py
Normal file
22
test_vsock/vsock_server.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import socket
|
||||
|
||||
CID = socket.VMADDR_CID_HOST
|
||||
PORT = 1234
|
||||
|
||||
s = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM)
|
||||
s.bind((CID, PORT))
|
||||
s.listen()
|
||||
(conn, (remote_cid, remote_port)) = s.accept()
|
||||
|
||||
print(f"Connection opened by cid={remote_cid} port={remote_port}")
|
||||
|
||||
while True:
|
||||
buf = conn.recv(64)
|
||||
if not buf:
|
||||
break
|
||||
|
||||
print(f"Received bytes: {buf}")
|
||||
|
||||
conn.send(b'Hello from host')
|
Reference in New Issue
Block a user