Hi,

I was trying to make a client/server application. Server listens at a specific port for an incoming connection and if there is a connection it accepts is and asks for a password. If password is correct then they simply wait for some "string" from eachother. everything is fine if I send and get data in string format. there is no problem at all!

(By the way I am using simple usual TcpListener/TcpClient, Networkstream, Binaryreader/writer, etc...

I decided to add file transfer option. well for that i needed to transfer data in byte arrays. Because of this I decided to make all data traffic in byte arrays. So I converted strings to arrays and arrays to string in between. In case of file transfer, file chunks are being sent with a cap like "[cap]"<data chunk>. This was my idea. On the other side there is a sub looking what is coming and what does it mean by looking its cap. In case of file transport specific cap, cap will be removed and data is being added to previous ones...

My problem was, that my binaryreader: reader reads incoming data without any parameter:
Code:
  1. message=reader.readstring

But in case of readbytes i have to put a parameter called count.
Well I don't know how much bytes are going to come until I get them. In case of TcpClient I can get it with: Client.GetStream.length.

But how can I get the same result with TcpListener? (At the server)

Can I transfer chunks of file bytes in string format and convert them back to bytearrays without any loss or problem?

Thanks in advance...