Click here to Skip to main content
15,908,111 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to make a plugin Pin
leppie6-Nov-02 10:31
leppie6-Nov-02 10:31 
GeneralRe: how to make a plugin Pin
Eric Gunnerson (msft)6-Nov-02 13:46
Eric Gunnerson (msft)6-Nov-02 13:46 
GeneralRe: how to make a plugin Pin
Philip Fitzsimons7-Nov-02 1:42
Philip Fitzsimons7-Nov-02 1:42 
GeneralRe: how to make a plugin Pin
Philip Fitzsimons7-Nov-02 1:45
Philip Fitzsimons7-Nov-02 1:45 
GeneralRe: how to make a plugin Pin
James T. Johnson7-Nov-02 2:41
James T. Johnson7-Nov-02 2:41 
AnswerRe: how to make a plugin Pin
Nnamdi Onyeyiri6-Nov-02 20:53
Nnamdi Onyeyiri6-Nov-02 20:53 
GeneralUsing Typed Datasets Pin
afronaut6-Nov-02 5:17
afronaut6-Nov-02 5:17 
GeneralRe: Using Typed Datasets Pin
leppie6-Nov-02 10:36
leppie6-Nov-02 10:36 
GeneralRe: Using Typed Datasets Pin
Eric Gunnerson (msft)6-Nov-02 13:41
Eric Gunnerson (msft)6-Nov-02 13:41 
Generaluploading stream to webserver Pin
Anonymous6-Nov-02 5:08
Anonymous6-Nov-02 5:08 
GeneralRe: uploading stream to webserver Pin
Philip Fitzsimons7-Nov-02 1:39
Philip Fitzsimons7-Nov-02 1:39 
GeneralRe: uploading stream to webserver Pin
Anonymous7-Nov-02 3:35
Anonymous7-Nov-02 3:35 
GeneralRe: uploading stream to webserver Pin
fftongzhi18-Nov-02 15:30
fftongzhi18-Nov-02 15:30 
QuestionAfter openining a word document in c-sharp,i got picture from it ,question is how to show this picture? Pin
Asim N.6-Nov-02 1:32
Asim N.6-Nov-02 1:32 
AnswerRe: After openining a word document in c-sharp,i got picture from it ,question is how to show this picture? Pin
Senkwe Chanda6-Nov-02 1:40
Senkwe Chanda6-Nov-02 1:40 
AnswerRe: After openining a word document in c-sharp,i got picture from it ,question is how to show this picture? Pin
Stephane Rodriguez.6-Nov-02 1:55
Stephane Rodriguez.6-Nov-02 1:55 
GeneralRe: After openining a word document in c-sharp,i got picture from it ,question is how to show this picture? Pin
Sijin6-Nov-02 2:39
Sijin6-Nov-02 2:39 
GeneralLinking with Word 9.0 while word 10.0 is installed Pin
Noam Ben Haim5-Nov-02 20:27
Noam Ben Haim5-Nov-02 20:27 
GeneralRe: Linking with Word 9.0 while word 10.0 is installed Pin
Stephane Rodriguez.5-Nov-02 20:42
Stephane Rodriguez.5-Nov-02 20:42 
GeneralRe: Linking with Word 9.0 while word 10.0 is installed Pin
Noam Ben Haim5-Nov-02 21:38
Noam Ben Haim5-Nov-02 21:38 
GeneralWeb Services DISCO party Pin
antoine@orchus-tech5-Nov-02 13:34
antoine@orchus-tech5-Nov-02 13:34 
Questionhow to login the system through a service? Pin
imran_rafique5-Nov-02 12:23
imran_rafique5-Nov-02 12:23 
AnswerRe: how to login the system through a service? Pin
Stephane Rodriguez.5-Nov-02 20:52
Stephane Rodriguez.5-Nov-02 20:52 
Questionhow to get a system state? Pin
imran_rafique5-Nov-02 12:10
imran_rafique5-Nov-02 12:10 
GeneralSynchronous socket connections Pin
m_mond5-Nov-02 8:53
m_mond5-Nov-02 8:53 
I'm trying to get a synchronous connection to a server using the various .NET stream classes. It seems that I can send a command to the server successfully, but nothing is returned (or the StreamReader returns before the data can be read off of the socket). Here's the psuedocode/real code :

static void Main(string[] args)
{
   string newsServerName	= "msnews.microsoft.com";
   int newsServerPort		= 119;

   TcpClient newsServer;

   try {
      newsServer = new TcpClient();
      newsServer.Connect( newsServerName, newsServerPort );
   }
   catch( SocketException e )
   {
      string error = "Failed to connect to " + newsServerName + " on port " + newsServerPort;
      Console.WriteLine( error );
      Console.WriteLine( e.Message );
      return;
   }

   NetworkStream netStream;
   StreamReader reader;
   StreamWriter writer;

   try {
      netStream = newsServer.GetStream();
      reader = new StreamReader( netStream );
      writer = new StreamWriter( netStream );

      // Flush the read buffer if there's anything in there from the Connect.
      if ( reader.Peek() > -1 ) {
         while ( reader.Peek() > -1 ) {
            Console.WriteLine( reader.ReadLine() );
         }
      }

      string sendMessage = "LIST" + "\r\n";

      Console.WriteLine( "Sending message." );
      writer.WriteLine( sendMessage );
      writer.Flush();
      Console.WriteLine( "Waiting for response." );
 

      while ( reader.Peek() > -1 ){
         Console.WriteLine( reader.ReadLine() );
      }
   }
   catch( Exception e ) {
      Console.WriteLine( "Error talking with server." );
      Console.WriteLine( e.Message );
   }
}


The last while loop never writes anything out. At the very least I should get the response from the server. How can I make the StreamReader wait until there is data before trying to dump out? I know this can be done with plain Send and Recv on a Socket, but I would like to use the Stream* classes if possible.

greg

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.