Click here to Skip to main content
15,569,768 members
Home / Discussions / C#
   

C#

 
QuestionMake main window wait for message box Pin
Lee Reid19-Oct-09 23:41
Lee Reid19-Oct-09 23:41 
AnswerRe: Make main window wait for message box Pin
dan!sh 19-Oct-09 23:50
professional dan!sh 19-Oct-09 23:50 
GeneralRe: Make main window wait for message box Pin
Lee Reid19-Oct-09 23:54
Lee Reid19-Oct-09 23:54 
AnswerRe: Make main window wait for message box Pin
Mirko198019-Oct-09 23:52
Mirko198019-Oct-09 23:52 
AnswerRe: Make main window wait for message box Pin
freakyit20-Oct-09 2:29
freakyit20-Oct-09 2:29 
QuestionC# to Nassi-Shneiderman diagram Pin
Herman<T>.Instance19-Oct-09 23:27
Herman<T>.Instance19-Oct-09 23:27 
AnswerRe: C# to Nassi-Shneiderman diagram Pin
V.20-Oct-09 0:15
professionalV.20-Oct-09 0:15 
Questionhow to send and recieve data from different ip using socket server Pin
Ajithevn19-Oct-09 22:32
Ajithevn19-Oct-09 22:32 
Hi all

sorry for reposting.Im using socket programming to send data from one system to another.im running client and server on both systems.my problem is when i send a message from client of one system it reaches the server of other system, how to send that recieved data to localhost client. below is the code:-

client:-

 private void sendButton_Click(object sender, EventArgs e)
        {            
            TcpClient socketForServer;
            try
            {
                socketForServer = new TcpClient(_ip of sending machine , 10);  
               
            }
            catch
            {
                MessageBox.Show("Failed to connect to server at {0}:999", _machineName); 
                return;
            }
            NetworkStream networkStream = socketForServer.GetStream();            
            System.IO.StreamWriter streamWriter =
            new System.IO.StreamWriter(networkStream);
            System.IO.StreamReader streamReader =
            new System.IO.StreamReader(networkStream);
            try
            {
                streamWriter.WriteLine(this.messageTextBox.Text);                    
                streamWriter.Flush();
                this.messageTextBox.Clear();
                this.messageTextBox.ReadOnly = true; 
                this.messageTextBox.Text = streamReader.ReadLine(); 
             
            }
            catch
            {
                MessageBox.Show("Exception reading from Server");  
            }
            // tidy up
            networkStream.Close();            

        }

Server:-

TcpListener tcpListener = new TcpListener(10);            
            tcpListener.Start();                       

            while (true)
            {
                Socket socketForClient = tcpListener.AcceptSocket();                
                NetworkStream networkStream = new NetworkStream(socketForClient);                
                System.IO.StreamReader streamReader =
                new System.IO.StreamReader(networkStream);               
                string theString = streamReader.ReadLine();
                MessageBox.Show(theString);  //message recieved how to send this back to local host           
                streamReader.Close();
                networkStream.Close();
                socketForClient.Close();
            }


IF Clinet-B connects to server and sends message, before disconnecting how can Client-A connect to servere.
AnswerRe: how to send and recieve data from different ip using socket server Pin
Richard MacCutchan19-Oct-09 23:58
mveRichard MacCutchan19-Oct-09 23:58 
GeneralRe: how to send and recieve data from different ip using socket server Pin
Ajithevn20-Oct-09 0:15
Ajithevn20-Oct-09 0:15 
GeneralRe: how to send and recieve data from different ip using socket server Pin
Richard MacCutchan20-Oct-09 1:03
mveRichard MacCutchan20-Oct-09 1:03 
QuestionRe: how to send and recieve data from different ip using socket server [modified] Pin
Ajithevn20-Oct-09 1:27
Ajithevn20-Oct-09 1:27 
AnswerRe: how to send and recieve data from different ip using socket server Pin
Richard MacCutchan20-Oct-09 2:24
mveRichard MacCutchan20-Oct-09 2:24 
GeneralRe: how to send and recieve data from different ip using socket server Pin
Ajithevn20-Oct-09 3:39
Ajithevn20-Oct-09 3:39 
AnswerRe: how to send and recieve data from different ip using socket server Pin
Jimmanuel20-Oct-09 4:12
Jimmanuel20-Oct-09 4:12 
QuestionMulti-threaded SOAP calls to different servers a problem? Pin
gstar4219-Oct-09 22:18
gstar4219-Oct-09 22:18 
AnswerRe: Multi-threaded SOAP calls to different servers a problem? Pin
Mirko198019-Oct-09 23:37
Mirko198019-Oct-09 23:37 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
gstar4220-Oct-09 5:08
gstar4220-Oct-09 5:08 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
Mirko198020-Oct-09 5:30
Mirko198020-Oct-09 5:30 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
gstar4220-Oct-09 5:33
gstar4220-Oct-09 5:33 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
Mirko198020-Oct-09 6:58
Mirko198020-Oct-09 6:58 
QuestionVideo display Pin
saran.m19-Oct-09 22:15
saran.m19-Oct-09 22:15 
AnswerRe: Video display Pin
Christian Graus20-Oct-09 1:04
mveChristian Graus20-Oct-09 1:04 
QuestionHow to insert data into a GridView from the textboxes Pin
Nopo19-Oct-09 21:55
Nopo19-Oct-09 21:55 
AnswerRe: How to insert data into a GridView from the textboxes Pin
Calla19-Oct-09 22:12
Calla19-Oct-09 22:12 

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.