Click here to Skip to main content
15,896,348 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to avoid closing mdiparent form while we close mdichild.? Pin
DaveyM696-May-11 7:11
professionalDaveyM696-May-11 7:11 
GeneralRe: How to avoid closing mdiparent form while we close mdichild.? Pin
Paramu19736-May-11 7:53
Paramu19736-May-11 7:53 
QuestionHow to Apply Proerty in Control Pin
Anubhava Dimri5-May-11 0:12
Anubhava Dimri5-May-11 0:12 
AnswerRe: How to Apply Proerty in Control Pin
dasblinkenlight5-May-11 0:29
dasblinkenlight5-May-11 0:29 
AnswerRe: How to Apply Proerty in Control Pin
Ravi Sant5-May-11 0:36
Ravi Sant5-May-11 0:36 
QuestionAdd virtual device Pin
Pranit Kothari4-May-11 23:43
Pranit Kothari4-May-11 23:43 
AnswerRe: Add virtual device Pin
Dave Kreskowiak5-May-11 1:47
mveDave Kreskowiak5-May-11 1:47 
GeneralRe: Add virtual device Pin
Pranit Kothari5-May-11 1:57
Pranit Kothari5-May-11 1:57 
GeneralRe: Add virtual device Pin
fjdiewornncalwe5-May-11 3:00
professionalfjdiewornncalwe5-May-11 3:00 
AnswerRe: Add virtual device Pin
jschell5-May-11 8:14
jschell5-May-11 8:14 
QuestionWeb Service Returns Null, No Exceptions Pin
GlobX4-May-11 17:26
GlobX4-May-11 17:26 
Questionhow to add the values from controls to class to read it in xml Pin
Rocky234-May-11 7:42
Rocky234-May-11 7:42 
QuestionConversion of List to DataTable Pin
Ankit Rajput4-May-11 0:45
Ankit Rajput4-May-11 0:45 
AnswerRe: Conversion of List to DataTable Pin
Peter_in_27804-May-11 0:59
professionalPeter_in_27804-May-11 0:59 
GeneralRe: Conversion of List to DataTable Pin
Ankit Rajput4-May-11 1:02
Ankit Rajput4-May-11 1:02 
GeneralRe: Conversion of List to DataTable Pin
Dave Kreskowiak4-May-11 1:14
mveDave Kreskowiak4-May-11 1:14 
GeneralRe: Conversion of List to DataTable Pin
Ankit Rajput4-May-11 1:22
Ankit Rajput4-May-11 1:22 
AnswerRe: Conversion of List to DataTable Pin
Blue_Boy4-May-11 1:13
Blue_Boy4-May-11 1:13 
JokeRe: Conversion of List to DataTable Pin
wizardzz4-May-11 7:39
wizardzz4-May-11 7:39 
AnswerRe: Conversion of List to DataTable Pin
wizardzz4-May-11 7:39
wizardzz4-May-11 7:39 
QuestionHow to axAcroPdf automatically perform click on save button Pin
cigara93933-May-11 22:05
cigara93933-May-11 22:05 
Question64 bit Console linked to 32 bit dll? Pin
devvvy3-May-11 16:59
devvvy3-May-11 16:59 
AnswerRe: 64 bit Console linked to 32 bit dll? Pin
Luc Pattyn3-May-11 17:30
sitebuilderLuc Pattyn3-May-11 17:30 
QuestionAsynchronous Response to a Synchronous TCPClient Pin
Octantis3-May-11 13:09
Octantis3-May-11 13:09 
I created some client server code that talks back and forth to each other using TCPListener -> TcpClient -> NetworkStream. Everything it working great. The data being sent from the client is showing up on the server with data intact. However, there is one problem; the data is out of order.

A simple example is:

Client sends:
1 2 3 4 5 6 7 8 9 10

and the Server receives:
1 2 3 5 6 7 8 4 9 10

I'm happy that the 4 makes it there but I'd just like it to come after the 3.

Is this a short coming of the TCP stack? Am I asking too much? I know tcp is supposed to ensure that data gets there but does it ensure that it gets there in order?

Some psuedo code as to the main line items:

m_Listener = new TcpListener(m_ServerPort);   <-- Port 8000 if it matters
m_Listener.Start();

TcpClient m_Client = m_Listner.AcceptTcpClient();
NetworkStream m_NetworkStream = m_Client.GetStream();


The below code is run in a thread devoted to reading in data from that network stream. This thread code is via a BackgroundWorker.

while (m_Client.Connected)
{
    //---------------------------------------------------------------------------------
    // Handle the processing of the incomming data as it comes in.
    // --------------------------------------------------------------------------------
    // Read the command's Type
    //---------------------------------------------------------------------------------
                    byte[] buffer = new byte[4];
                    int readBytes = m_NetworkStream.Read(buffer, 0, 4);
                    if (readBytes == 0)
                        break;
                    ChatCommandType cmdType = (ChatCommandType)(BitConverter.ToInt32(buffer, 0));

                    //---------------------------------------------------------------------------------
                    // Read the command's target size
                    //---------------------------------------------------------------------------------
                    string cmdTarget = "";
                    buffer = new byte[4];
					readBytes = m_NetworkStream.Read(buffer, 0, 4);
                    if (readBytes == 0)
                        break;
                    int ipSize = BitConverter.ToInt32(buffer, 0);

                    //---------------------------------------------------------------------------------
                    // Read the command's target
                    //---------------------------------------------------------------------------------
                    buffer = new byte[ipSize];
					readBytes = m_NetworkStream.Read(buffer, 0, ipSize);
                    if (readBytes == 0)
                        break;
                    cmdTarget = System.Text.Encoding.ASCII.GetString(buffer);
}


There is more to the read in code but this is the gist.

It runs rock solid except when the entire messages get flipped.

I'd appreciate any random thoughts on this. I've been banging my head on it for 2 days now and need a fresh pair of eyes.

I could implement my own sync code where it won't send 5 until it gets a response on 4 but I thought TcpClient would be the one to handle that and not higher up the stack.

Thanks,
AnswerRe: Asynchronous Response to a Synchronous TCPClient Pin
Luc Pattyn3-May-11 13:25
sitebuilderLuc Pattyn3-May-11 13:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.