Click here to Skip to main content
15,919,931 members
Home / Discussions / C#
   

C#

 
AnswerRe: not able to read data from excel sheet using Microsoft.Office.Interop.Excel Pin
Dave Kreskowiak2-Oct-09 5:28
mveDave Kreskowiak2-Oct-09 5:28 
GeneralRe: not able to read data from excel sheet using Microsoft.Office.Interop.Excel Pin
PrasannaKulkarni2-Oct-09 6:19
PrasannaKulkarni2-Oct-09 6:19 
GeneralRe: not able to read data from excel sheet using Microsoft.Office.Interop.Excel Pin
Dave Kreskowiak2-Oct-09 7:05
mveDave Kreskowiak2-Oct-09 7:05 
QuestionCannot convert from system...IList<class> to class[]</class> Pin
Sevententh2-Oct-09 4:09
Sevententh2-Oct-09 4:09 
AnswerRe: Cannot convert from system...IList to class[] Pin
Keith Barrow2-Oct-09 4:19
professionalKeith Barrow2-Oct-09 4:19 
GeneralRe: Cannot convert from system...IList to class[] Pin
Sevententh5-Oct-09 23:27
Sevententh5-Oct-09 23:27 
QuestionOdd behaviour when selecting item in a Combobox [Fixed it, my fault] Pin
Anthony Mushrow2-Oct-09 4:07
professionalAnthony Mushrow2-Oct-09 4:07 
QuestionC# TCP networkstreem problem Pin
Titok Levi2-Oct-09 2:32
Titok Levi2-Oct-09 2:32 
Hi.
I got a server and a client application. Server sends bytes to client in TCP. But the problem is that it's "too fast" I mean in a way. For be more specific. I have objects of a class (in a List) in the server side, I format that to xml string, and then format the string to bytes and send this byte array.

//Client:

//...
NetworkStream = new NetworkStream(SocketClient);
while (ListOfObjectToSendOut.Count > 0) //For example 5 times, cause i have 5 Object in my List
{
    //...Formating to XML string
    //...Convert string to byteArray (BytesToSend)
                            
    NetworkStream.Write(BytesToSend, 0, BytesToSend.Length);
    NetworkStream.Flush();
     
    //I have to take this here, BUT I DONT WANT THAT
    Thread.Sleep(100);
}


//Server:
TcpClient myClient = new TcpClient("localhost", 8000);

NetworkStream NetworkStream = myClient.GetStream();
byte[] bytes = new byte[3000];
while (true)
{
    int IncomingByteLength = NetworkStream.Read(incomingBytes, 0, 3000);       //VÁR bejövő adatra

    //Convert incomingBytes to (XML) string
    //string to MyClass
}


You can ask, what's my problem?. Let's say that the Object I want to send is 150 bytes long. And I want to send out 5 Object. My problem that i need to happen this in an order like this:

Write 150 byte
Read 150 byte (and than "unformat" it)
Write 150 byte
Read 150 byte (and than "unformat" it)
and so on.

With this way I could unfomate the 150 byte in the Client side.

BUT!!! In a real world it will write out 150 byte and 150 byte again and so on and THAN the Client will Read 450 or 600 or 750 bytes. It is imponderable. And I CAN NOT unformat 300 or 450 ... to my Object. So the Flush doesn't flush it (I read in msdn that it is ok, cause flush wont do anything with the networkstream)So the problem is that the Server sends out 150 bytes and send out the next 150 bytes so fast that the Client will read those together (for example 300 bytes), which is not good.

I need to READ THIS "PACKAGES" SEPARATE in the client side.



- I can solve this to write a Thread.Sleep(100) but i dont want to do that, It would be to slow!
- I can solve this proble using UDP, but i dont want to use UDP.
- I could solve this porblem with a a solution like:
Take a sign byte after every 150 byte, and seperate in the client side by that sign. And then format the bytes back. But I dont want to do that.

- I tried Socket.NoDelay doesn't help
- I tired close and dispose and than make it again the networkStream in EVERY loop. It doesnt help.

Now all you programmers, here is a big deal, Who is the Best Programmer? Roll eyes | :rolleyes: What can I do? (I hope you can understand my problem Sniff | :^) )
Thanks!
AnswerRe: C# TCP networkstreem problem Pin
Luc Pattyn2-Oct-09 3:06
sitebuilderLuc Pattyn2-Oct-09 3:06 
AnswerRe: C# TCP networkstreem problem Pin
0x3c02-Oct-09 3:56
0x3c02-Oct-09 3:56 
AnswerRe: C# TCP networkstreem problem Pin
Tr@v2-Oct-09 16:26
Tr@v2-Oct-09 16:26 
GeneralRe: C# TCP networkstreem problem Pin
Titok Levi6-Oct-09 22:03
Titok Levi6-Oct-09 22:03 
QuestionGenerics, delegates and type inference Pin
dojohansen2-Oct-09 2:10
dojohansen2-Oct-09 2:10 
AnswerRe: Generics, delegates and type inference Pin
Gideon Engelberth2-Oct-09 6:29
Gideon Engelberth2-Oct-09 6:29 
GeneralRe: Generics, delegates and type inference Pin
dojohansen2-Oct-09 7:43
dojohansen2-Oct-09 7:43 
GeneralRe: Generics, delegates and type inference Pin
Gideon Engelberth2-Oct-09 13:00
Gideon Engelberth2-Oct-09 13:00 
QuestionInheritance question Pin
xkrja1-Oct-09 23:35
xkrja1-Oct-09 23:35 
AnswerRe: Inheritance question Pin
stancrm1-Oct-09 23:49
stancrm1-Oct-09 23:49 
GeneralRe: Inheritance question Pin
xkrja2-Oct-09 0:22
xkrja2-Oct-09 0:22 
GeneralRe: Inheritance question Pin
Mirko19802-Oct-09 0:57
Mirko19802-Oct-09 0:57 
AnswerRe: Inheritance question Pin
Christian Graus2-Oct-09 0:40
protectorChristian Graus2-Oct-09 0:40 
AnswerRe: Inheritance question Pin
DaveyM692-Oct-09 0:46
professionalDaveyM692-Oct-09 0:46 
AnswerRe: Inheritance question Pin
dojohansen3-Oct-09 1:12
dojohansen3-Oct-09 1:12 
QuestionStream System Sound to A GSM MODEM Pin
aghoshbabu1-Oct-09 23:09
aghoshbabu1-Oct-09 23:09 
AnswerRe: Stream System Sound to A GSM MODEM Pin
Rutvik Dave2-Oct-09 4:27
professionalRutvik Dave2-Oct-09 4:27 

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.