Click here to Skip to main content

C#

    RSS: RSS Feed
Home > Forums > C#

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
GeneralRe: better way to make function returns PinmemberSaksida Bojan7:59 20 Nov '09  
AnswerRe: better way to make function returns Pinmember0x3c07:38 20 Nov '09  
AnswerRe: better way to make function returns Pinmembermusefan8:39 20 Nov '09  
GeneralRe: better way to make function returns PinmembernetJP12L9:34 20 Nov '09  
AnswerRe: better way to make function returns Pinmemberdojohansen11:59 23 Nov '09  
QuestionStream closes while reading a socket Pinmemberjoana.simoes6:11 20 Nov '09  
AnswerRe: Stream closes while reading a socket PinmemberPaulo Zemek6:57 20 Nov '09  
Why do you read from the outstream???
 
buffer = new byte[BUFFER_SIZE];
                        Stream outstream = response.GetResponseStream();
                        int outcount = outstream.Read(buffer, 0, buffer.Length);
                        while (outcount > 0)
                        {
                            context.Response.OutputStream.Write(buffer, 0, outcount);
                            outcount = outstream.Read(buffer, 0, buffer.Length);
                        }
 

I think you should read from instream and write to outstream.
Maybe that's the problem (I am not sure, as I don't have the full source).
 

Also, I think the best pattern is:
Create a TcpListener.
Start it.
In a loop, you accept a TcpClient, start a thread to process the client and continues in the loop accepting new requests.
 
In the thread, you read all and send all.
 
And, finally, maybe the connection is lost in the middle. This can happen (think about the stop button, for example). So, if the connection is closed, it's ok. Ignore this exception.
GeneralRe: Stream closes while reading a socket Pinmemberjoana.simoes7:19 20 Nov '09  
GeneralRe: Stream closes while reading a socket PinmemberPaulo Zemek8:44 22 Nov '09  
AnswerRe: Stream closes while reading a socket PinmvpLuc Pattyn7:27 20 Nov '09  
GeneralRe: Stream closes while reading a socket Pinmemberjoana.simoes1:13 23 Nov '09  
GeneralRe: Stream closes while reading a socket Pinmemberjoana.simoes1:39 23 Nov '09  
GeneralRe: Stream closes while reading a socket PinmvpLuc Pattyn1:43 23 Nov '09  
GeneralRe: Stream closes while reading a socket Pinmemberjoana.simoes4:56 23 Nov '09  
NewsRe: Stream closes while reading a socket Pinmemberjoana.simoes7:43 23 Nov '09  
AnswerRe: Stream closes while reading a socket Pinmemberdojohansen12:15 23 Nov '09  
NewsRe: Stream closes while reading a socket Pinmemberjoana.simoes2:37 24 Nov '09  
QuestionExcel Formatting. PinmemberFEMDEV5:47 20 Nov '09  
AnswerRe: Excel Formatting. Pinmembertoby319:16 20 Nov '09  
GeneralRe: Excel Formatting. PinmemberFEMDEV23:44 22 Nov '09  
QuestionSQLite Pinmemberjashimu4:26 20 Nov '09  
AnswerRe: SQLite PinmemberMeLight4:35 20 Nov '09  
GeneralRe: SQLite Pinmemberjashimu5:44 20 Nov '09  
GeneralRe: SQLite PinmvpPete O'Hanlon6:04 20 Nov '09  
GeneralRe: SQLite PinmemberPIEBALDconsult9:04 20 Nov '09  

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

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


Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 14 Feb 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid