public void Judge() { try { //string CodePath = "E:\\tmp\\tmp"+Language; //string BinaryPath = "E:\\tmp\\tmp.exe"; //File.WriteAllText(CodePath, Source); using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { bool con = false; while(!con) try { sock.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6000)); con = true; } catch { con = false; } string Compile = ""; if (Language == ".cpp") Compile = "g++ -o {Execute}{.cpp} {Source}"; if (Language==".c") Compile = "gcc -o {Execute}{.c} {Source}"; if (Language==".pas") Compile = "fpc -o{Execute}{.pas} {Source}"; sock.Send(new Message() { Type = Message.MessageType.Compile, Content = new CompileIn() { Code = Source, Command = Compile, Memory = 1024 * 1024 * 60, Time = 5 * 1000 } }.ToBytes()); Out ret = new Out(sock); Response.Write("<div class=\"style2\" style=\"text-align:left; padding-top:20px; padding-left:20px;\">编译信息:</div>"); Response.Write("<div style=\"color:green; text-align:left; padding-left:30px;\"" + ret.CompileMessage() + "</div>"); if (ret.ErrorCode == 0) { Response.Write("<div class=\"style2\" style=\"text-align:left; padding-top:20px; padding-left:20px;\">测试点信息:</div>"); for (int i = 0; i < TestNum; ++i) { //Response.Write("??:"+FilePath+"\\input\\"+InFile[i]+" "+FilePath+"\\output\\"+OutFile[i]); sock.Send(new Message() { Type = Message.MessageType.Test, Content = new TestIn() { CmpPath = "E:\\tmp\\Special_Judge.exe", ExecPath = ret.Message, Memory = 1024 * 1024 * 30, Time = 1000, Input = File.ReadAllBytes(FilePath + "\\input\\" + InFile[i]), Output = File.ReadAllBytes(FilePath + "\\output\\" + OutFile[i]) } }.ToBytes()); ret = new Out(sock); Response.Write("<div style=\"color:green; text-align:left; padding-left:30px;\">"); Response.Write("#"+(i+1).ToString()+": "+ret.RunMessage()+"</div>"); } } } } catch (Exception exp) { } }