Click here to Skip to main content
16,013,642 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with Listview,help! Pin
Luc Pattyn5-Jun-10 8:46
sitebuilderLuc Pattyn5-Jun-10 8:46 
GeneralRe: Problem with Listview,help! Pin
Henry Minute5-Jun-10 9:05
Henry Minute5-Jun-10 9:05 
GeneralRe: Problem with Listview,help! Pin
Luc Pattyn5-Jun-10 11:38
sitebuilderLuc Pattyn5-Jun-10 11:38 
GeneralRe: Problem with Listview,help! Pin
Henry Minute5-Jun-10 11:43
Henry Minute5-Jun-10 11:43 
GeneralRe: Problem with Listview,help! Pin
Luc Pattyn5-Jun-10 11:55
sitebuilderLuc Pattyn5-Jun-10 11:55 
GeneralRe: Problem with Listview,help! Pin
imbiz5-Jun-10 16:02
imbiz5-Jun-10 16:02 
GeneralRe: Problem with Listview,help! Pin
imbiz5-Jun-10 16:21
imbiz5-Jun-10 16:21 
QuestionUsing connection continuously Pin
teknolog1235-Jun-10 6:36
teknolog1235-Jun-10 6:36 
hi, I'm using below code for a basic client/server communication. I send a string to server and server sends it back to client with no problem. But I can do this only once and then connection goes, what should I do to be able to send more strings one after other without loosing the connection? Thanks in advance

/// Server Code:
private void button1_Click(object sender, EventArgs e)
       {
           TcpListener tcpListen = new TcpListener(IPAddress.Parse("192.168.1.6"), 1234);
           tcpListen.Start();
           Socket socket = tcpListen.AcceptSocket();

           if (socket.Connected)
           {
               while (true)
               {
                   NetworkStream stream = new NetworkStream(socket);
                   StreamReader streamRead = new StreamReader(stream);
                   StreamWriter streamWrite = new StreamWriter(stream);
                   try
                   {
                       streamWrite.WriteLine("Incoming message: " + streamRead.ReadLine());
                       streamWrite.Flush();
                   }
                   catch (Exception)
                   {
                       label1.Text = "Server is being shutdown";
                       return;
                   }
               }
           }
           socket.Close();
       }

/// Client Code:
public TcpClient client;
        NetworkStream stream;
        StreamReader streamRead;
        StreamWriter streamWrite;

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                client = new TcpClient("192.168.1.6", 1234);
            }
            catch (Exception)
            {
                MessageBox.Show("Not Connected");
            }
            stream = client.GetStream();
            streamRead = new StreamReader(stream);
            streamWrite = new StreamWriter(stream);

            try
            {
                streamWrite.WriteLine(textBox1.Text);
                streamWrite.Flush();
                string line = streamRead.ReadLine();
                MessageBox.Show("Message from server: " + line);
            }
            catch (Exception)
            {
                MessageBox.Show("Connection error");
            }
            streamWrite.Close();
            streamRead.Close();
            stream.Close();
        }

AnswerRe: Using connection continuously Pin
Not Active5-Jun-10 7:02
mentorNot Active5-Jun-10 7:02 
GeneralRe: Using connection continuously Pin
teknolog1235-Jun-10 8:30
teknolog1235-Jun-10 8:30 
GeneralRe: Using connection continuously Pin
Luc Pattyn5-Jun-10 8:50
sitebuilderLuc Pattyn5-Jun-10 8:50 
AnswerRe: Using connection continuously Pin
Luc Pattyn5-Jun-10 7:19
sitebuilderLuc Pattyn5-Jun-10 7:19 
AnswerRe: Using connection continuously Pin
Erik Funkenbusch6-Jun-10 11:01
Erik Funkenbusch6-Jun-10 11:01 
QuestionComplex SQL Insert Query Pin
TenRC5-Jun-10 5:05
TenRC5-Jun-10 5:05 
AnswerRe: Complex SQL Insert Query Pin
Not Active5-Jun-10 6:58
mentorNot Active5-Jun-10 6:58 
GeneralRe: Complex SQL Insert Query Pin
TenRC5-Jun-10 13:23
TenRC5-Jun-10 13:23 
QuestionEF question -- get a name of a table [modified] Pin
Lutosław5-Jun-10 4:49
Lutosław5-Jun-10 4:49 
AnswerRe: EF question -- get a name of a table Pin
Not Active5-Jun-10 6:51
mentorNot Active5-Jun-10 6:51 
GeneralRe: EF question -- get a name of a table Pin
Lutosław5-Jun-10 12:14
Lutosław5-Jun-10 12:14 
GeneralRe: EF question -- get a name of a table Pin
Not Active5-Jun-10 13:03
mentorNot Active5-Jun-10 13:03 
GeneralRe: EF question -- get a name of a table Pin
Lutosław5-Jun-10 13:50
Lutosław5-Jun-10 13:50 
GeneralRe: EF question -- get a name of a table Pin
Not Active5-Jun-10 15:18
mentorNot Active5-Jun-10 15:18 
GeneralRe: EF question -- get a name of a table Pin
Lutosław6-Jun-10 4:04
Lutosław6-Jun-10 4:04 
Questionhow to handle Server Not found exception at client side in .net remoting? Pin
amit_834-Jun-10 22:48
professionalamit_834-Jun-10 22:48 
AnswerRe: how to handle Server Not found exception at client side in .net remoting? Pin
#realJSOP5-Jun-10 2:02
professional#realJSOP5-Jun-10 2:02 

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.