欢迎来到论文网!
识人者智,自知者明,通过生日认识自己! 生日公历:
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
年
1
2
3
4
5
6
7
8
9
10
11
12
月
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
日
网站地图
|
Tags标签
|
RSS
论文网8200余万篇毕业论文、各种论文格式和论文范文以及9千多种期刊杂志的论文征稿及论文投稿信息,是论文写作、论文投稿和论文发表的论文参考网站,也是科研人员论文检测和发表论文的理想平台。lunwenf@yeah.net。
论文网
论文一百问
论文发表
毕业论文
教学论文
经济管理
科技论文
医药卫生
社会科学
论文网博客
搜论文:
高级搜索
您当前的位置:
首页
>
科技论文
>
计算机论文
多站点水情信息编码并发传输模式
时间:2010-11-30 作者:秩名
1.1.1 为了保证所传输编码的完整性,网络传输协议应该采用稳定的协议,因此不采用UDP等协议,采用HTTP,确保传输过程中不出现数据包丢失的现象。发表论文。
1.1.2多个水情分站要同时向水情总站传输水情信息编码时,必须保证传输的并发执行,通过建立一个TThreadList类来实现多线程并发执行,该类是一个线程安全的list类,并保证传输完毕后能够安全释放线程空间。 1.1.3 水情信息编码在输入计算机时,可能由于人为或者其他原因造成编码格式或编码的数据错误,为了提高编码格式正确性和数据精确度,需要构造一种数据结构对编码的输入和输出进行校验。
2 采用服务器/客户端模式解决
水情中心站作为服务器端,负责接收和转发水情信息代码。
水情分站作为客户端,将收集到的水情信息传输给中心站。
三 具体实现
1 服务器端处理水情信息编码的核心程序代码
//全局类型声明
type
PClient = ^TClient;//指向该结构的一个指针
TClient = record //构造一个结构,用来存储客户端传来的数据
DNS :String[20]; // 客户端IP
Connected,//连接时间
LastAction :TDateTime; //最后一次提交的时间
Thread :Pointer;//指向线程的指针
end;
//全局变量声明
var
FormMain:TFormMain;
ParseThread: TTeleParse; //生成一个验证水情信息编码的对象
Clients :TThreadList; //生成一个线程安全的 List类,保证并发执行时线程同步
procedureTFormMain.FormCreate(Sender: TObject);
varappDir:string;
begin
//主站配置文件
tsinitSElement:=TinitSElement.Create('D:\xxx水利局\主程序\codebase.ini');
//验证水情信息编码
ParseThread:=TTeleParse.Create(True);
ParseThread.SElement:= tsinitSElement.SELement;
//服务器段验证
appDir:=extractFilePath(application.exename);
IdServerIOHandlerSSL.SSLOptions.KeyFile:= AppDir + 'sample.key';
IdServerIOHandlerSSL.SSLOptions.CertFile:= AppDir + 'sample.crt';
IdServerIOHandlerSSL.SSLOptions.RootCertFile:= AppDir + 'sampleRoot.pem';
Clients :=TThreadList.Create;
TeleList:=TStringList.Create;
timer1.enabled:= true;
end;
//用一个timer对象来激活IdTCPServer
procedureTFormMain.Timer1Timer(Sender: TObject);
begin
timer1.enabled:= false;
ParseThread.Resume;
IdTCPServer.Active :=true;
end;
procedureTFormMain.IdTCPServerDisconnect(AThread: TIdPeerThread);
begin
FreeIdPeerThread(AThread); //断开连接释放ip
end;
//服务器端建立连接,并开启线程空间
procedureTFormMain.IdTCPServerConnect(AThread: TIdPeerThread);
var
NewClient:PClient;
begin
GetMem(NewClient, SizeOf(TClient)); // 分配一个动态内存空间
NewClient.DNS :=AThread.Connection.Socket.Binding.PeerIP; //获取客户端IP
NewClient.Connected := Now;
NewClient.LastAction := NewClient.Connected;
NewClient.Thread :=AThread;
AThread.Data:=TObject(NewClient);
try
Clients.LockList.Add(NewClient); // 同步,只允许当前的客户端连接线程进行操作,其他线程等待
finally
Clients.UnlockList; //解锁
end;
AThread.Connection.WriteLn('和主站连接成功'); //连接成功返回给客户端信息
end;
procedureTFormMain.FreeIdPeerThread(AThread: TIdPeerThread);
var
ActClient:PClient;
begin
ActClient :=PClient(AThread.Data);
try
Clients.LockList.Remove(ActClient); //同步,只允许当前的客户端连接线程进行操作,其他线程等待
finally
Clients.UnlockList;//解锁
end;
FreeMem(ActClient);
AThread.Data:= nil;
end;
//服务器端接收客户端的文件传送
procedureTFormMain.IdTCPServerExecute(AThread: TIdPeerThread);
varTeleText:string;
RecClient: PClient;
i:integer;
strIP:string;
RecThread: TIdPeerThread;
begin
if (notAThread.Terminated) and (AThread.Connection.Connected) then
try
TeleText:= Trim(AThread.connection.ReadLn); //将客户端传来的水情信息编码写如teletext;
if AThread.Connection.Socket.Connected then
strIP:=AThread.Connection.Socket.Binding.PeerIP;
else
begin
with Clients.LockList do//循环条件,对当前的客户端连接线程进行操作
try
for i := 0 to Count-1 do
begin
RecClient:=Items[i];
if RecClient.DNS=strIP then // we don't have a login function so we haveto use the DNS
begin
RecThread:=RecClient.Thread;
RecThread.Connection.WriteLn('>>水情信息编码已经成功传送完毕');
end;
end;
finally
Clients.UnlockList;//解锁
end;
if TeleText<>'' then
TeleList.Append(TeleText);
end;
except
AThread.Connection.Disconnect;
end;
2水情信息编码校验
2.1 构造一个循环链表对象,将输入、输出的水情信息编码存入该循环链表对象,生成的水情信息编码循环链表示意如下:
2
/
3
首页
上一页
1
2
3
下一页
尾页
查看相关论文专题
:
加入收藏
打印本文
上一篇论文:
例谈VB批改操作题的实现
下一篇论文:
高职院校Oracle数据库的教学探讨_项目驱动教学法-论文网
科技论文分类
科技小论文
数学建模论文
数学论文
节能减排论文
数学小论文
低碳生活论文
物理论文
建筑工程论文
网站设计论文
农业论文
图书情报
环境保护论文
计算机论文
化学论文
机电一体化论文
生物论文
网络安全论文
机械论文
水利论文
地质论文
交通论文
相关计算机论文
无相关信息
最新计算机论文
读者推荐的计算机论文
搜索论文:
高级搜索
热门
:
计算机
会计
电子商务
人工智能
汽车
网站论文网
|
论文格式
|
论文范文
|
毕业论文
|
网站地图
|
免责声明
|
WAP
Powered by
EmpireCMS
© 2002-2011
鲁ICP备19008790号-1