1

I'm currently receiving text:

private void ReceiveCallback(IAsyncResult AR)
{
    try
    {
        int received = _clientSocket.EndReceive(AR);

        //string text = Encoding.ASCII.GetString(_buffer);
        Array.Resize(ref _buffer, received);
        //AppendToTextBox(text);
        Array.Resize(ref _buffer, _clientSocket.ReceiveBufferSize);
        _clientSocket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

How can I read an image, instead of text?

1 Answer 1

1

You'd probably want to wait to receive the entire thing, and then:

using(var ms = new MemoryStream(entireBuffer)) {
    var image = Image.FromStream(ms);

    // Go ahead and put it in a PictureBox now
}
Sign up to request clarification or add additional context in comments.

1 Comment

thank you.but now it is saying "parameter is not valid" i m gonna write every codes.in other question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.