Tongda OA uses C # Socket programming to replace Socket operations in PHP. Tongda OA adopts the PHP language for programming. Similarly, some operations on IM use Socket for communication. Recently, a program needs to be implemented using C #, which involves this part. it is rewritten using C #. further test results are required.
Using System; using System. collections. generic; using System. net; using System. net. sockets; using System. text; using System. threading; namespace monitorFlowworkAndSubmit. DAL {class SendSocket {string mya_tdim_addr = "127.0.0.1"; int mya_tdim_port = xxxx; public string Send () {string rst = ""; // Set the server ip address IPAddress ip = IPAddress. parse (mya_tdim_addr); Socket clientSocket = new Socket (AddressFamily. in TerNetwork, SocketType. dgram, ProtocolType. udp); try {clientSocket. connect (new IPEndPoint (ip, mya_tdim_port); // Configure the server IP address and port Console. writeLine ("successfully connected to the server");} catch (Exception ex) {rst = "failed to connect to the server. press enter to exit! "; Return ex. toString () ;}try {string sendMessage = "x ^ a ^ admin"; clientSocket. send (Encoding. ASCII. getBytes (sendMessage); Console. writeLine ("send message to server: {0}" + sendMessage);} catch {clientSocket. shutdown (SocketShutdown. both); clientSocket. close (); return "sed err";} return "OK ";}}}