I’m working a client/server application where I have to read bytes from the data received on the server. I’m trying to convert it from Java to C# but I can’t seem to solve this one! T
Java code:
byte[] bucket = new byte[4];
this.socket.getInputStream().read(bucket, 0, 2);
And now I need the same code in C#! Hope you can help me out!
If you want a like-for-like port, the most sensible thing is probably to wrap the socket in a
NetworkStream, which then acts a lot like thegetInputStreamresult (except you would only do it once), i.e.but remember to ensure that
nsis disposed when you are done (ideally viausing). If you want to use the socket directly, you’ll have to use theReceivemethod on the socket.