资源简介
多线程UDP接收到数据,并对数据进行存储
代码片段和文件信息
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Gps.MonitorService
{
public class MonitorServer
{
private static UdpClient listener;
private IPAddress IPAddr;
private const int port = 8080;
private Thread listenerThread = null;
public MonitorServer(string IP)
{
this.IPAddr = IPAddress.Parse(IP);
}
private static void WriteLog(string ex)
{
string path = @System.Environment.CurrentDirectory;
try
{
if (Directory.Exists(path))
{
string filename = path + “Error.txt“;
FileInfo myfile = new FileInfo(filename);
if (!myfile.Exists)
{
FileStream newfile = myfile.OpenWrite();
newfile.Close();
}
StreamWriter write = new StreamWriter(filename true);
write.WriteLine(ex);
write.Flush();
write.Close();
}
else
{
Directory.CreateDirectory(path);
string filename = path + “Error.txt“;
FileStream newfile = File.Create(filename);
newfile.Flush();
newfile.Close();
StreamWriter write = new StreamWriter(filename);
write.WriteLine(ex);
write.Flush();
write.Close();
}
}
catch (Exception ex1)
{
}
}
private static void SaveMessage(string mgs)
{
string path = @System.Environment.CurrentDirectory;
try
{
if (Directory.Exists(path))
{
string filename = path + “Message.txt“;
FileInfo myfile = new FileInfo(filename);
if (!myfile.Exists)
{
FileStream newfile = myfile.OpenWrite();
newfile.Close();
}
StreamWriter write = new StreamWriter(filename true);
write.WriteLine(mgs);
write.Flush();
write.Close();
}
else
{
Directory.CreateDirectory(path);
string filename = path + “Message.txt“;
FileStream newfile = File.Create(filename);
newfile.Flush();
newfile.Close();
StreamWrit
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1426 2016-08-04 16:17 Monitor\Backup\GPS_Monitor.sln
..A..H. 39424 2016-08-28 18:07 Monitor\Backup\GPS_Monitor.suo
文件 5052 2016-08-28 17:48 Monitor\Backup\WindowsServer\MonitorServer.cs
文件 2515 2016-08-04 16:33 Monitor\Backup\WindowsServer\MonitorServer.csproj
文件 1358 2016-08-01 14:41 Monitor\Backup\WindowsServer\Properties\AssemblyInfo.cs
文件 544 2016-08-01 14:42 Monitor\Backup\WindowsService1\MonitorService.cs
文件 2776 2016-08-01 14:48 Monitor\Backup\WindowsService1\MonitorService.csproj
文件 1099 2016-08-01 14:43 Monitor\Backup\WindowsService1\MonitorService.Designer.cs
文件 518 2016-08-01 14:44 Monitor\Backup\WindowsService1\Program.cs
文件 1362 2016-08-01 14:36 Monitor\Backup\WindowsService1\Properties\AssemblyInfo.cs
文件 1426 2016-08-30 15:27 Monitor\GPS_Monitor.sln
..A..H. 47616 2016-09-11 18:09 Monitor\GPS_Monitor.suo
文件 3799 2016-08-30 15:27 Monitor\UpgradeLog.xm
文件 4096 2016-08-01 14:48 Monitor\WindowsServer\bin\Debug\ClassLibrary1.dll
文件 7680 2016-08-01 14:48 Monitor\WindowsServer\bin\Debug\ClassLibrary1.pdb
文件 6144 2016-09-11 17:46 Monitor\WindowsServer\bin\Debug\MonitorService.dll
文件 17920 2016-09-11 17:46 Monitor\WindowsServer\bin\Debug\MonitorService.pdb
文件 5052 2016-08-28 17:48 Monitor\WindowsServer\MonitorServer.cs
文件 4176 2016-08-30 15:27 Monitor\WindowsServer\MonitorServer.csproj
文件 452 2016-08-30 15:27 Monitor\WindowsServer\MonitorServer.csproj.user
文件 538 2016-08-01 14:42 Monitor\WindowsServer\obj\Debug\ClassLibrary1.csproj.FileListAbsolute.txt
文件 4096 2016-08-01 14:48 Monitor\WindowsServer\obj\Debug\ClassLibrary1.dll
文件 5791 2016-09-11 17:46 Monitor\WindowsServer\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1428 2016-09-11 17:46 Monitor\WindowsServer\obj\Debug\MonitorServer.csproj.FileListAbsolute.txt
文件 6144 2016-09-11 17:46 Monitor\WindowsServer\obj\Debug\MonitorService.dll
文件 17920 2016-09-11 17:46 Monitor\WindowsServer\obj\Debug\MonitorService.pdb
文件 4096 2016-08-04 16:24 Monitor\WindowsServer\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 1358 2016-08-01 14:41 Monitor\WindowsServer\Properties\AssemblyInfo.cs
文件 5120 2016-09-11 17:45 Monitor\WindowsService1\bin\Debug\WindowsService1.exe
文件 19968 2016-09-11 17:45 Monitor\WindowsService1\bin\Debug\WindowsService1.pdb
............此处省略46个文件信息
- 上一篇:win7蓝牙万能驱动
- 下一篇:毕设程序89C51计算器程序+proteus仿真
相关资源
- 使用选择性重传协议实现UDP可靠通信
- 编写简单的RMI程序 多线程web 服务器
- 网络(UDP)转串口程序
- 多线程生产者消费者模式
- 用Socket写的简易FTP服务器和客户端
- socket小工具(可方便建立TCP UDP的soc
- UDP组播的发送和接收程序
- 多线程实例:桌面智能弹球小游戏
- 采用WINSOCK2 编写的TCP/UDP通信程序
- WPF多线程演示
- 易语言:多线程传多变量的最稳定方
- 使用FRS-ESR对储存的富含中子的129130
- TCP_UDP对结构体加密数据传输
- IBM System Storage DS6000小型模块化扩展结
- 欧姆龙以太网通讯TCP/UDP及欧姆龙PLC程
- 迈拓与AMCC合作企业级SATA储存方案
- UDP协议进行P2P打洞
- 各大商家统一存储产品分析
- 排队买票多线程问题
- 强大的完善的 活动抽奖系统适合各单
- 十字路口红绿灯交通情况模拟
- 计算机网络socket编程实验
- UDP P2P打洞服务器
- Qt 多线程连接数据库——数据库
- 易语言多线程端口扫描源码
- POSIX多线程程序设计中文版源码
- 易语言md5定向爆破源码
- 一个老外写的RUDP的源代码
- udp丢包率统计
- Socket-UDP整合消息接收,发送
评论
共有 条评论