Tongda OA uses C # Socket programming to replace Socket operations in PHP

Source: Internet
Author: User
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 ";}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.