tcpclient: slow connection
이전 댓글 표시
The following:
t = tcpclient('localhost', port);
takes about 2sec instead of being instantaneous.
I'm connecting to a python server (runs in a short script), which was tested with a python client.
An example server:
#!/usr/bin/env python3
import socket
HOST = '127.0.0.1'
PORT = 65432
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
print( data )
An example client:
%echotcpip( "on", 65432 )
tic;
%t = tcpclient( '127.0.0.1', 65432 );
t = tcpclient( 'localhost', 65432 );
toc;
write(t, uint8('hi'));
clear t
%echotcpip("off")
Playing with it further:
- There's no slowdown when connecting to echotcpip.
- If I connect to '127.0.0.1', there's no slowdown. According to the doc, this address uses IPv4, while 'localhost' uses IPv6. Maybe it's something with my win10 (which is totally unreliable, and you can't know what they break each update).
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Parallel Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!