日期:2014-05-17 浏览次数:20819 次
private void RecThread(Socket client) { Thread Rec = new Thread(new ThreadStart(this.Receive)); Rec.Start(client); } private void Receive(Socket client) { . . . }
static void Main(string[] args) { SendMessage sm = new SendMessage(c); Thread sendThread = new Thread(new ThreadStart(sm.sendMessage)); sendThread.Start(); } public class SendMessage { private Socket s; public SendMessage(Socket param_socket) { this.s = param_socket; } public void sendMessage() { while(true) { string content = Console.ReadLine(); if (content == "Close") { Console.WriteLine("You have AFK!"); break; } else { byte[] sendBytes = Encoding.ASCII.GetBytes(content); s.Send(sendBytes, sendBytes.Length, 0); } } } }