Could someone shed some light on this problem for me, please?
I have a SocketListener and a Client winforms apps, they're based on the examples from MS:
client,
listener.
This Send method is done programmatically:
private void Send(Socket handler, String data)
{
byte[] byteData = Encoding.ASCII.GetBytes(data);
handler.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), handler);
}
I would like to do it with a button.
What I have tried:
private void btnTcp1_Click(object sender, EventArgs e)
{
string data = "";
Socket handler;
data = tBoxTcpSend.Text;
byte[] byteData = Encoding.ASCII.GetBytes(data);
handler.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), handler);
}
I have tried this, but I'm getting: Use of unassigned local variable 'handler'.
I also tried to make a copy of Send method, and assign it to btnTcp1 click event, but that doesn't work either.