通达oa中采用了php的语言来进行编程,同样对于im的有些操作则采用了socket的方式进行通讯。最近做的一个程序需要采用c#来做,里面涉及到这块,采用c#进行了重写,具体还需要进一步进行测试效果。
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";
}
}
}以上就是通达OA 使用C#的Socket编程来其替代原有操作的示例代码分享的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号