Click here to Skip to main content
15,902,938 members
Home / Discussions / C#
   

C#

 
GeneralRe: Merging or adding 2 different DataTables into Single DataTable Pin
K V Sekhar11-Jan-10 15:39
K V Sekhar11-Jan-10 15:39 
GeneralRe: Merging or adding 2 different DataTables into Single DataTable Pin
Dave Kreskowiak11-Jan-10 17:29
mveDave Kreskowiak11-Jan-10 17:29 
QuestionBlocking Queue Pin
ika211-Jan-10 3:38
ika211-Jan-10 3:38 
AnswerRe: Blocking Queue Pin
harold aptroot11-Jan-10 3:41
harold aptroot11-Jan-10 3:41 
GeneralRe: Blocking Queue Pin
ika211-Jan-10 4:18
ika211-Jan-10 4:18 
GeneralRe: Blocking Queue [modified] Pin
harold aptroot11-Jan-10 4:32
harold aptroot11-Jan-10 4:32 
AnswerRe: Blocking Queue Pin
Nicholas Butler11-Jan-10 5:31
sitebuilderNicholas Butler11-Jan-10 5:31 
QuestionProblem at second connection attempt Pin
sleepyman11-Jan-10 3:29
sleepyman11-Jan-10 3:29 
Hi.
I am making just a simple socket program. Server program is always working. When I open client program and click the button, sending/receiving data normally. Everything's ok. But when I close client and opening again, and then clicking button, client program getting lock. Not getting error. When I debug, its waiting on "readline" line. What is the problem? Why its not working when I reopen client program?

Client
private void Form1_Load(object sender, EventArgs e)
        {
           
            try
            {
                tcp_client = new TcpClient("192.168.1.222", 4444);
            }
            catch
            {
                label2.Text = "not connected";
                return;
            }

            ag_akimi = tcp_client.GetStream();
            akim_okuyucu = new StreamReader(ag_akimi);
            akim_yazici = new StreamWriter(ag_akimi);
          
        }


        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                akim_yazici.WriteLine("sample ");
                akim_yazici.Flush();
                textBox1.Text += akim_okuyucu.ReadLine();
            }
            catch
            {
                MessageBox.Show("error!");
            }

        }

        private void form_kapatiliyor(object sender, FormClosingEventArgs e)
        {
            try
            {
                akim_okuyucu.Close();
                akim_yazici.Close();
                ag_akimi.Close();
                istemcisoketi.Close();
            }
            catch
            {
                MessageBox.Show("Not properly closed");
            }
        }
    }

***********************************************
server

public void Form1_Load(object sender, EventArgs e)
       {
           CheckForIllegalCrossThreadCalls = false;
           thread_dinleyici = new Thread(new ThreadStart(dinle));
           thread_dinleyici.Start();
       }


       public void dinle()
       {
           tcp_listener = new TcpListener(IPAddress.Any, 4444);
           tcp_listener.Start();
           istemcisoketi = tcp_listener.AcceptSocket();
           ag_akimi = new NetworkStream(istemcisoketi);

           if (istemcisoketi.Connected)
           {
               while (true)
               {
                   akim_yazici = new StreamWriter(ag_akimi);
                   akim_okuyucu = new StreamReader(ag_akimi);
                   try
                   {
                       richTextBox1.Text += akim_okuyucu.ReadLine();
                       akim_yazici.WriteLine("message");
                       akim_yazici.Flush();
                   }
                   catch
                   {
                       label1.Text = "closing";
                       istemcisoketi.Close();
                       ag_akimi.Close();
                       akim_yazici.Close();
                       akim_okuyucu.Close();
                       istemcisoketi.Close();
                       return;
                   }
               }
           }
           else
           {
           }

       }

AnswerRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:06
mveOriginalGriff11-Jan-10 4:06 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 4:15
sleepyman11-Jan-10 4:15 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:37
mveOriginalGriff11-Jan-10 4:37 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 5:57
sleepyman11-Jan-10 5:57 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 8:19
mveOriginalGriff11-Jan-10 8:19 
QuestionRead in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:04
elmernite11-Jan-10 3:04 
AnswerMessage Closed Pin
11-Jan-10 3:14
stancrm11-Jan-10 3:14 
QuestionRe: Read in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:24
elmernite11-Jan-10 3:24 
QuestionWhat's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 2:34
arnold_w11-Jan-10 2:34 
AnswerRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 3:32
professional dan!sh 11-Jan-10 3:32 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:39
arnold_w11-Jan-10 3:39 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 3:45
professional dan!sh 11-Jan-10 3:45 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:50
arnold_w11-Jan-10 3:50 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:53
arnold_w11-Jan-10 3:53 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 4:00
professional dan!sh 11-Jan-10 4:00 
QuestionCustom Control expandable property ordering [solved] Pin
OriginalGriff11-Jan-10 1:54
mveOriginalGriff11-Jan-10 1:54 
AnswerRe: Custom Control expandable property ordering. Pin
Martin#11-Jan-10 3:43
Martin#11-Jan-10 3:43 

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.