Click here to Skip to main content
15,900,973 members
Home / Discussions / C#
   

C#

 
QuestionMethod Overload Troubles? Pin
Marcel Cartier9-May-15 16:42
Marcel Cartier9-May-15 16:42 
AnswerRe: Method Overload Troubles? PinPopular
OriginalGriff9-May-15 19:57
mveOriginalGriff9-May-15 19:57 
Questionwebbrowser auto tab click Pin
esancakdar8-May-15 2:17
esancakdar8-May-15 2:17 
AnswerRe: webbrowser auto tab click Pin
Dave Kreskowiak8-May-15 3:49
mveDave Kreskowiak8-May-15 3:49 
AnswerRe: webbrowser auto tab click Pin
Dr Gadgit10-May-15 4:29
Dr Gadgit10-May-15 4:29 
QuestionHow Do I Pin
Cianide8-May-15 2:00
Cianide8-May-15 2:00 
SuggestionRe: How Do I Pin
ZurdoDev8-May-15 2:20
professionalZurdoDev8-May-15 2:20 
GeneralRe: How Do I Pin
Cianide8-May-15 3:14
Cianide8-May-15 3:14 
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 

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.