Tongda OA uses C # Socket programming to replace the original operation.

Source: Internet
Author: User

Tongda OA uses C # Socket programming to replace the original operation.

Tongda OA adopts the PHP language for programming, and some IM operations adopt 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 MYOA_TDIM_ADDR = "127.0.0.1";        int MYOA_TDIM_PORT = xxxx;        public string Send()        {            string rst = "";                        IPAddress ip = IPAddress.Parse(MYOA_TDIM_ADDR);            Socket clientSocket = new Socket(AddressFamily.InterNetwork,                                         SocketType.Dgram,ProtocolType.Udp);            try            {                clientSocket.Connect(new IPEndPoint(ip, MYOA_TDIM_PORT));                 Console.WriteLine("conn OK");            }            catch (Exception ex)            {                rst = "conn err!";                return ex.ToString();            }            try            {                 string sendMessage = "x^a^admin";                 clientSocket.Send(Encoding.ASCII.GetBytes(sendMessage));                            }            catch            {                 clientSocket.Shutdown(SocketShutdown.Both);                 clientSocket.Close();                 return "send error";            }            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.