I have an application in vb.net which will connect with an hardware device and test its functionality. The hardware device basically spits out data continuosly through ethernet. That is it recieves some data via com ports and spits out the processed data via ethernet.
So my application does both. Thats pretty much the entire app.
My problem is i am using tcpclient sockets. Now when i connect a tcpclient to the device using
tcpclient.open(开发者_Python百科ip,port);
Immediately the device sends some data which comes and get stored in the clientsocket. Then i send a command to it ,only then i read the data from the clientsocket using
tcpclient.getstream().read()
at this time the entire data that is the one which flowed immediately when connected to the device and the one that i actually need after passing command is both acquired. This is undesirable. I need the data which i read only after sending the command.
So i was wondering if there is any way to clear the tcpclient socket before we do a read. The manual doesnt show any such method.
Any help on this would be useful to me.
You need to read the stream before sending the command to read out the stuff you're not interested in.
精彩评论