MATLAB: How to read LAN data’s in m-file

reading lan data's

hi,
I sent data from my pc to another pc, only the values sent shows the data. while i am reading in another pc, its not getting read. where sholud i do the mistake?
t=tcpip('192.168.1.4',80) // another pc name
bytesToRead=50;
t.BytesAvailableFcnMode='byte'
t.BytesAvailableFcnCount=bytesToread
fopen(t)
pause(3)
fwrite(t,1:255)
pause(3)
fclose(t)
now, in inspector element, i can see changes in valuesent=255 whereas, the same program only i did in another pc for reading
t=tcpip('192.168.1.4',80) // another pc name
bytesToRead=50;
t.BytesAvailableFcnMode='byte'
t.BytesAvailableFcnCount=bytesToread
fopen(t)
pause(3)
fread(t,255)
pause(3)
fclose(t)
instead of writing. but, there i am not able to see changes in inspector element.how should i do this?

Best Answer

t=tcpip('192.168.1.4',80) is the command to use on a "client" (the one that initiates the conversation) that needs to connect to a "server" (the one that the conversation is initiated to.)
So it is fine to use it on the first PC to start the conversation to the second PC (provided the second PC's IP address is 192.168.1.4), but when you use it on the second PC, if the second PC really is 192.168.1.4, it would be a request to connect from the second PC's MATLAB to the second PC's web server. On the second PC, you need to instead use a tcpip() command indicating that you want to receive conversations. See the text starting with "Start a TCP/IP server socke" over in http://blogs.mathworks.com/loren/2011/05/27/transferring-data-between-two-computers-using-matlab/