Click here to Skip to main content
15,892,674 members
Home / Discussions / C#
   

C#

 
AnswerRe: Accessing form controls from WCF service Pin
DaveyM6915-Nov-10 13:00
professionalDaveyM6915-Nov-10 13:00 
AnswerRe: Accessing form controls from WCF service Pin
PIEBALDconsult15-Nov-10 14:22
mvePIEBALDconsult15-Nov-10 14:22 
AnswerRe: Accessing form controls from WCF service Pin
si2480315-Nov-10 22:45
si2480315-Nov-10 22:45 
GeneralRe: Accessing form controls from WCF service Pin
teknolog12316-Nov-10 3:17
teknolog12316-Nov-10 3:17 
AnswerRe: Accessing form controls from WCF service Pin
si2480316-Nov-10 4:51
si2480316-Nov-10 4:51 
GeneralRe: Accessing form controls from WCF service Pin
teknolog12318-Nov-10 7:34
teknolog12318-Nov-10 7:34 
AnswerRe: Accessing form controls from WCF service Pin
Daniel Vaughan15-Nov-10 23:41
Daniel Vaughan15-Nov-10 23:41 
Question"No connection could be made because the target machine actively refused it" Pin
Megidolaon14-Nov-10 22:31
Megidolaon14-Nov-10 22:31 
I get this error when trying to send something between two apps over TCP.
The weird part is that I can send one time without any trouble, but whenever I try a second time, I get this error.
I use this code for the sending app:
private void B_Send_Click(object sender, EventArgs e)
        {
            string send = "";
            send = TB_Quotes.Text;
            
            TcpClient tcp = new TcpClient(TB_Host.Text, (int)UD_Port.Value);
            NetworkStream ns = tcp.GetStream();
            StreamWriter writer = new StreamWriter(ns);

            writer.WriteLine(send);
            writer.Flush();
           
            ns.Close();
            writer.Close();
            tcp.Close();
        }

And this code for the receiving app:
public Form1()
        {
            InitializeComponent();
            Thread treceive = new Thread(new ThreadStart(Listen));
            treceive.Start();
        }

        public void Listen()
        {
            int port = 2112;
            string result = "";
            IPAddress localaddress = IPAddress.Parse("127.0.0.1");
            TcpListener listener = new TcpListener(localaddress, port);
            listener.Start();
            
            TcpClient client = listener.AcceptTcpClient();
            NetworkStream ns = client.GetStream();
            StreamReader reader = new StreamReader(ns);
            
            result = reader.ReadToEnd();
            Invoke(new UpdateDisplayDelegate(UpdateDisplay), new object[] {result});
        }
        public void UpdateDisplay(string text)
        {
            TB_Quotes.Text = text;
        }


I'm making sure the port is 2112 (if not, the first time would not be successful), but I don't understand why the 2nd time won't work.

Thanks.
AnswerRe: "No connection could be made because the target machine actively refused it" Pin
Manfred Rudolf Bihy14-Nov-10 22:49
professionalManfred Rudolf Bihy14-Nov-10 22:49 
GeneralRe: "No connection could be made because the target machine actively refused it" Pin
Megidolaon14-Nov-10 22:56
Megidolaon14-Nov-10 22:56 
GeneralRe: "No connection could be made because the target machine actively refused it" Pin
Manfred Rudolf Bihy14-Nov-10 22:58
professionalManfred Rudolf Bihy14-Nov-10 22:58 
AnswerRe: "No connection could be made because the target machine actively refused it" Pin
Luc Pattyn15-Nov-10 3:37
sitebuilderLuc Pattyn15-Nov-10 3:37 
Questionthreshold filter problem Pin
pancakeleh14-Nov-10 22:03
pancakeleh14-Nov-10 22:03 
AnswerRe: threshold filter problem Pin
OriginalGriff14-Nov-10 23:27
mveOriginalGriff14-Nov-10 23:27 
GeneralIMPORT EXCEL TO SQL Pin
black0714-Nov-10 21:52
black0714-Nov-10 21:52 
GeneralRe: IMPORT EXCEL TO SQL Pin
Dave Kreskowiak15-Nov-10 2:00
mveDave Kreskowiak15-Nov-10 2:00 
GeneralRe: IMPORT EXCEL TO SQL Pin
musefan15-Nov-10 2:33
musefan15-Nov-10 2:33 
QuestionXML Serialization Pin
NarVish14-Nov-10 21:18
NarVish14-Nov-10 21:18 
AnswerRe: XML Serialization Pin
Manfred Rudolf Bihy14-Nov-10 22:02
professionalManfred Rudolf Bihy14-Nov-10 22:02 
GeneralRe: XML Serialization Pin
NarVish14-Nov-10 22:09
NarVish14-Nov-10 22:09 
GeneralRe: XML Serialization Pin
Manfred Rudolf Bihy14-Nov-10 22:14
professionalManfred Rudolf Bihy14-Nov-10 22:14 
GeneralRe: XML Serialization Pin
NarVish14-Nov-10 22:31
NarVish14-Nov-10 22:31 
GeneralRe: XML Serialization Pin
Manfred Rudolf Bihy14-Nov-10 22:59
professionalManfred Rudolf Bihy14-Nov-10 22:59 
GeneralRe: XML Serialization Pin
NarVish14-Nov-10 23:09
NarVish14-Nov-10 23:09 
Questionimage procesing get text from image Pin
TAREQ F ABUZUHRI14-Nov-10 21:07
TAREQ F ABUZUHRI14-Nov-10 21:07 

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.