我附带个有的难度的问题
class config()
{
public Socket ClientSocket;
private void button1_Click_1(object sender, EventArgs e)
{
IPEndPoint ServerInfo = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Convert.ToInt32(6000));
Socket ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
ClientSocket.Connect(ServerInfo);
MessageBox.Show("连接成功!", "提示");
}
}
class program()
{
fmConfig pfmConfig = new fmConfig();
public bool SendToClient(string data)
{
try
{
byte[] sendBuffer = new byte[10240];
int dataLen = System.Text.Encoding.UTF8.GetBytes(data, 0, data.Length, sendBuffer, 4); //utf8编码
sendBuffer[0] = 0x1F;
sendBuffer[1] = 0xF1;
CopyByte(sendBuffer, 2, dataLen, 2);
dataLen += 4;
pfmConfig.ClientSocket.BeginSend(sendBuffer, 0, dataLen, 0, new AsyncCallback(SendCallBack), pfmConfig.ClientSocket);//这条语句
return true;
}
catch (Exception e)
{
return false;
}
}
}
上面的那条语句想调用config类中的ClientSocket,可以吗,有什么问题?