Click here to Skip to main content
15,890,185 members
Home / Discussions / C#
   

C#

 
AnswerRe: How Do I PinPopular
Pete O'Hanlon8-May-15 2:24
mvePete O'Hanlon8-May-15 2:24 
GeneralRe: How Do I Pin
Cianide8-May-15 2:35
Cianide8-May-15 2:35 
GeneralRe: How Do I Pin
Pete O'Hanlon8-May-15 2:37
mvePete O'Hanlon8-May-15 2:37 
GeneralRe: How Do I Pin
Cianide8-May-15 3:16
Cianide8-May-15 3:16 
GeneralRe: How Do I Pin
Mycroft Holmes8-May-15 13:52
professionalMycroft Holmes8-May-15 13:52 
GeneralRe: How Do I Pin
ZurdoDev8-May-15 3:16
professionalZurdoDev8-May-15 3:16 
Questionreceived data by UDP client Pin
hasan hadi7-May-15 21:43
hasan hadi7-May-15 21:43 
AnswerRe: received data by UDP client Pin
F-ES Sitecore9-May-15 2:25
professionalF-ES Sitecore9-May-15 2:25 
Your code relies on things we don't have access to, but this worked for me, if it works for you too then maybe analyse the differences (button1 connects and button2 sends)
public partial class Form1 : Form
{
    Thread listenThread;
    UdpClient udpClient;
    IPEndPoint ipend;
    bool listening;

    public Form1()
    {

        InitializeComponent();
        udpClient = new UdpClient();

    }

    private void send_data_through_etherent(string send_data_ETH)
    {

        byte[] senddataETH = ASCIIEncoding.ASCII.GetBytes(send_data_ETH);

        udpClient.Send(senddataETH, 4);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        int port;
        button1.Text = "disconnected";
        port = int.Parse(textBox2.Text);
        ipend = new IPEndPoint(IPAddress.Parse(textBox1.Text), port);

        try
        {

            udpClient.Connect(ipend);
            button1.Text = "Connected";

        }
        catch (Exception e1)
        {
            MessageBox.Show(e1.ToString());
        }

        listenThread = new System.Threading.Thread(StartListening);
        listenThread.Start();

    }

    public void StartListening()
    {
        UdpClient c = new UdpClient(ipend);

        string data = string.Empty;

        do
        {
            byte[] reciveddata = c.Receive(ref ipend);
            data = Encoding.ASCII.GetString(reciveddata);

            System.Diagnostics.Debug.WriteLine(data);

            if (listening)
            {
                label3.Invoke((MethodInvoker)delegate { label3.Text += data; });
            }

        } while (data != "exit");

    }

    private void button2_Click(object sender, EventArgs e)
    {

        send_data_through_etherent("S11E");
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        listening = false;
        send_data_through_etherent("exit");
    }

}

GeneralRe: received data by UDP client Pin
hasan hadi9-May-15 3:38
hasan hadi9-May-15 3:38 
GeneralRe: received data by UDP client Pin
F-ES Sitecore9-May-15 7:05
professionalF-ES Sitecore9-May-15 7:05 
GeneralRe: received data by UDP client Pin
hasan hadi9-May-15 7:42
hasan hadi9-May-15 7:42 
GeneralRe: received data by UDP client Pin
F-ES Sitecore9-May-15 7:48
professionalF-ES Sitecore9-May-15 7:48 
GeneralRe: received data by UDP client Pin
hasan hadi9-May-15 8:07
hasan hadi9-May-15 8:07 
AnswerRe: received data by UDP client Pin
Dr Gadgit10-May-15 5:03
Dr Gadgit10-May-15 5:03 
Question(solved) shorter syntax for invoking static methods in generic non-static class ? Pin
BillWoodruff7-May-15 20:41
professionalBillWoodruff7-May-15 20:41 
AnswerRe: shorter syntax for invoking static methods in generic non-static class ? Pin
Sascha Lefèvre7-May-15 22:31
professionalSascha Lefèvre7-May-15 22:31 
GeneralRe: shorter syntax for invoking static methods in generic non-static class ? Pin
BillWoodruff7-May-15 22:46
professionalBillWoodruff7-May-15 22:46 
GeneralRe: shorter syntax for invoking static methods in generic non-static class ? Pin
Sascha Lefèvre7-May-15 23:53
professionalSascha Lefèvre7-May-15 23:53 
GeneralRe: shorter syntax for invoking static methods in generic non-static class ? Pin
BillWoodruff8-May-15 0:40
professionalBillWoodruff8-May-15 0:40 
GeneralRe: shorter syntax for invoking static methods in generic non-static class ? Pin
Sascha Lefèvre8-May-15 5:27
professionalSascha Lefèvre8-May-15 5:27 
SuggestionRe: shorter syntax for invoking static methods in generic non-static class ? Pin
Richard Deeming8-May-15 0:42
mveRichard Deeming8-May-15 0:42 
Questionhow do I get datasource to put to any drive c# Pin
Member 97020587-May-15 14:19
Member 97020587-May-15 14:19 
AnswerRe: how do I get datasource to put to any drive c# Pin
Dave Kreskowiak7-May-15 16:50
mveDave Kreskowiak7-May-15 16:50 
AnswerRe: how do I get datasource to put to any drive c# Pin
OriginalGriff7-May-15 20:35
mveOriginalGriff7-May-15 20:35 
AnswerRe: how do I get datasource to put to any drive c# Pin
Richard Deeming8-May-15 0:35
mveRichard Deeming8-May-15 0:35 

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.