Question:

Why is my asynchronous method in C# only sending the first 3 characters?

by Guest66440  |  earlier

0 LIKES UnLike

Hi there.

For the past three weeks I'm struggling with this.

I use an asynchronous method to send data from my client to server.

The Sender is:

Object objData = finMess;

byte[] byData = System.Text.Encoding.Default.GetBytes(ob...

if (m_clientSocket != null)

{

m_clientSocket.Send(byData);

}

with finMess ( a predifined string) with a value as 99984. But it only sends through "999".

The Recevier's code is:

int iRx = 0;

// Complete the BeginReceive() asynchronous call by EndReceive() method

// which will return the number of characters written to the stream

// by the client

iRx = socketData.m_currentSocket.EndReceive(as...

char[] chars = new char[iRx + 1];

System.Text.Decoder d = System.Text.Encoding.Default.GetDecoder(...

int charLen = d.GetChars(socketData.dataBuffer,

0, iRx, chars, 0);

System.String szData = new System.String(chars);

Then I append szData and take it in a String.

But the value only comes out as "999".

I use sockets for this. A worker_socket and a client_socket.

Can anyone with the expertise PLEASE HELP?

Thanks!

 Tags:

   Report

1 ANSWERS


  1. try changing the send method to

    m_clientSocket.Send(byData, byData.Length,0);

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.