using pnet for tcp/ip connection in matlab

22 views (last 30 days)
g
g on 28 May 2014
I am trying to use pnet to do a client-server opertaion in matlab. I think it should be very simple, but I dont know why I dont seem to be receiving anything on the client side. This is my code, any examples is really appreciated!!
server:
udp1 = pnet('tcpsocket',port1);
pnet(udp1,'setwritetimeout',2);
val = pnet(udp1,'tcplisten');
if val~=-1,
while 1
%get data
pnet(val,'write',data);
end
end
------------------------------------
client:
udpB=pnet('tcpconnect','localhost',lport);
pnet(udpB,'setreadtimeout',2);
sockcon=pnet('tcpsocket',lport);
while
data_read = pnet(sockcon,'read',100,'double');
end
--------------------------------------
the udp1 and udpB values are not -1, so there is a connection.however the data_read value is []. Why????

Answers (0)

Categories

Find more on Application Deployment in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!