I am trying to communicate between python and C++ via UNIX socket in Windows 10 64bit.
According to the documentation, to use UNIX sockets I need to set the family as AF_UNIX
instead of AF_INET
, and create a temporary local socket. This seems to be possible in Windows since last year, but I haven't found a clear explanation on how to do it.
I currently have this setting:
Server python
HOST = '127.0.0.1'
PORT = 5555
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
# Do something with recv(), send()
....
Client C++
WSADATA WSAData;
SOCKET server;
SOCKADDR_IN addr;
WSAStartup(MAKEWORD(2,0), &WSAData);
server = socket(AF_INET, SOCK_STREAM, 0);
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
addr.sin_family = AF_INET;
addr.sin_port = htons(5555);
connect(server, (SOCKADDR *)&addr, sizeof(addr));
// Do something with recv(), send()
Since this communication is pretty slow for my purpose, I want to do the same but using a UNIX socket. How can I do that? Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.