networking - TCP/IP Matlab between 2 Computers on the same Network -
i'm trying send info in bits 1 computer 1 on same network using tcp in matlab.
currently have setup open connections. i'm trying simulate peer-to-peer connection because need send , receive info each other. works fine on local machine when run using ipv4 , ipv6.
%code starts in 1 file openrecieve('0.0.0.0', 3000); %accept connections opensend('10.32.41.235',3000);
then same in file , can run them parallel on machine:
%code starts in other file opensend('10.32.41.235',3000); %ipv4 of pc openrecieve('0.0.0.0', 3000); %accept connections
the ips bogus...... code works on machine when run 2 different instances of matlab open. doesn't work between 2 different computers.
code openreceive:
function connectionserver = openrecieve(client, port) t = tcpip('0.0.0.0', port, 'networkrole', 'server'); set(t, 'inputbuffersize', 3000000); % open connection client. fopen(t); fprintf('%s \n','client connected'); connectionserver = t; set(connectionserver,'timeout',.1); end
code opensend:
function connectionsend = opensend(host, port) d = tcpip(host, port, 'networkrole', 'client'); set(d, 'outputbuffersize', 3000000); % set size of receiving buffer, if needed. %trying open connection server. while(1) seek fopen(d); break; grab fprintf('%s \n','cant find server'); end end connectionsend = d; end
any help appreciated.
it running although thing changed port numbers 3000 , 3000 3000 , 3001.......... using ipv4 pretty key network didn't allow ipv6.
for trying write tcp code in matlab utilize '0.0.0.0' connection if don't care connecting take ips trying connect on port #.
current code first file:
sconec = opensend('10.234.24.124', 3000); %ipv4 address of comp trying connect rconec = openrecieve('0.0.0.0', 3001); %accept connections
current code sec file:
rconec = openrecieve('0.0.0.0', 3000); %accept connections sconec = opensend('10.109.22.142', 3001); %ipv4 address of computer trying connect
matlab networking tcp
No comments:
Post a Comment