短信猫 服务端:

IdTCPServer1: TIdTCPServer;
IdAntiFreeze1: TIdAntiFreeze;

unit UnitSever;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPServer, IdAntiFreezeBase,
IdAntiFreeze, StdCtrls, ExtCtrls, Sockets, IdUDPBase, IdUDPServer,UGBBig5Convert,Comobj, WordXP,
DB, DBTables, Buttons,OleServer,ExcelXP,ADODB, IdCustomTCPServer; type
TRevData=record
Data:string;
Flag:Boolean;
end; TDataThread=class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor Create(data:string);
end; TSeverFrm = class(TForm)
IdTCPServer1: TIdTCPServer;
IdAntiFreeze1: TIdAntiFreeze;
ButtonStart: TButton;
ButtonClose: TButton;
Memo1: TMemo;
Panel1: TPanel;
GroupBox2: TGroupBox;
Label1: TLabel;
Edit_COM: TEdit;
Label2: TLabel;
Edit_Tel: TEdit;
Label3: TLabel;
Button_Send: TButton;
Button1: TButton;
label_conn: TLabel;
memo_sms_txt: TMemo;
label_sms_stact: TLabel;
ListBox1: TListBox;
Button2: TButton;
procedure ButtonStartClick(Sender: TObject);
procedure ButtonCloseClick(Sender: TObject);
procedure IdTCPServer1Connect(AThread: TIdPeerThread);
procedure IdTCPServer1Execute(AThread: TIdPeerThread);
procedure IdTCPServer1Disconnect(AThread: TIdPeerThread);
procedure Button1Click(Sender: TObject);
procedure Button_SendClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
//procedure Button2Click(Sender: TObject);
// procedure SpeedButton1Click(Sender: TObject);
// procedure ListBox1Click(Sender: TObject);
// procedure ListBox2Click(Sender: TObject);
private
{ Private declarations }
procedure WhileGetMSGdo;
function ServerReadBuffer(AThread: TIdPeerThread):string;
procedure ServerWtiteBuffer(AThread: TIdPeerThread;strMSG:string);
public
{ Public declarations }
sRevData:string;
end; function Sms_Connection(CopyRight:pchar;Com_Port,Com_BaudRate:integer;var Mobile_Type,CopyRightToCOM:PChar):integer;stdcall;external 'sms.dll';
function Sms_Send(Sms_TelNum:string;Sms_Text:string):integer;stdcall;external 'sms.dll';
Function Sms_Receive(Sms_Type:string;var Sms_Text:PChar):integer;stdcall;external 'sms.dll';
function Sms_Delete(Sms_Index:string):integer;stdcall;external 'sms.dll';
function Sms_AutoFlag :integer;stdcall;external 'sms.dll';
function Sms_NewFlag :integer;stdcall;external 'sms.dll';
function Sms_Disconnection :integer;stdcall;external 'sms.dll'; var
SeverFrm: TSeverFrm; implementation {$R *.dfm} function AppPath: string;
begin
Result := ExtractFilePath(Application.ExeName);
end; procedure WriteLog(s,Path:string);
var
TXT: TextFile;
begin
// FileStr := 'ERROR: '+FormatDateTime('YYYY-MM-DD HH:MM:SS',Now)+' | '+s;
try
AssignFile(TXT,Path + 'log.txt');
if FileExists(Path + 'log.txt') then
Append(TXT)
else
Rewrite(TXT);
Writeln(TXT,s);
Flush(TXT);
finally
CloseFile(TXT);
end;
end; procedure TDataThread.Execute();
begin
repeat until terminated ;
end; constructor TDataThread.Create(data:string);
begin end; function TSeverFrm.ServerReadBuffer(AThread: TIdPeerThread):string;
var
ts:TStrings;
stream:TStream;
begin
try
stream := TStringStream.Create(''); //ノㄤ摸Stream钡Μぃ摸计沮
AThread.Connection.ReadStream(stream);
stream.Position :=;
ts.LoadFromStream(stream);
Result := ts.Text;
finally
stream.Free;
end;
end; procedure TSeverFrm.ServerWtiteBuffer(AThread: TIdPeerThread;strMSG:string);
var
ts:TStrings;
stream:TStream;
begin
try
stream := TStringStream.Create(strMSG);
AThread.Connection.WriteStream(stream);
finally
stream.Free;
end;
end; procedure TSeverFrm.ButtonStartClick(Sender: TObject);
begin
IdTCPServer1.Active := True;
ButtonStart.Enabled := False;
ButtonClose.Enabled := True;
Memo1.Lines.Add('MSG: Successful Server Startup...');
end; procedure TSeverFrm.ButtonCloseClick(Sender: TObject);
begin
IdTCPServer1.Active := False;
ButtonStart.Enabled := True;
ButtonClose.Enabled := False;
Memo1.Lines.Add('MSG: Server is Down...');
end; procedure TSeverFrm.IdTCPServer1Connect(AThread: TIdPeerThread);
begin
try
Memo1.Lines.Add('MSG: Host'+AThread.Connection.Socket.Binding.PeerIP+'Connect Server OK');
AThread.Connection.WriteLn('Connect To Server Success...'); //临琌BufferH摆fuck
//ServerWtiteBuffer(AThread,'硈钡Θ');
finally end;
end; procedure TSeverFrm.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
if AThread=nil then Exit;
if not AThread.Connection.Connected then Exit;
if AThread.Terminated then Exit;
try
sRevData := AThread.Connection.ReadLn();
if Pos('SENDMSG',sRevData)> then
begin
memo1.Lines.Add(sRevData) ;
memo_sms_txt.Text:=sRevData;
AThread.Synchronize(WhileGetMSGdo);
AThread.Connection.WriteLn('Send Success');
end;
except
WriteLog('ERROR: '+DateTimeToStr(Now)+' | '+AThread.Connection.Socket.Binding.PeerIP+' Receive Data Eexception',AppPath);
end; end;
procedure TSeverFrm.WhileGetMSGdo; //め狠祇癳㏑ㄓ才兵ン秈︽矪瞶
begin
sRevData:=memo_sms_txt.Text;
Button_Send.Click;
{if Sms_Send(Trim(Edit_Tel.Text),memo_sms_txt.Text)=1 then
label_sms_stact.Caption := 'Send Success+'
else
label_sms_stact.Caption := 'Send Failed'; }
end; procedure TSeverFrm.IdTCPServer1Disconnect(AThread: TIdPeerThread);
begin
AThread.Connection.WriteLn('Server Is Down...');
end; procedure TSeverFrm.Button1Click(Sender: TObject);
var
Mobile_Type:pchar;
CopyRight:pchar;
CopyRightToCOM:pchar;
begin
CopyRight:=PChar('//上海迅赛信息技术有限公司,网址www.xunsai.com//'); //硂琿絏璶叫ぃ璶э
if Sms_Connection(CopyRight,StrToInt(Edit_COM.text),,Mobile_Type,CopyRightToCOM)<> then
begin
Label_conn.Caption:='OK:'+Mobile_Type+'!';
end
else
Label_conn.Caption:='NOT OK!'
end; procedure TSeverFrm.Button_SendClick(Sender: TObject);
var
i:Integer;
begin
{if Sms_Send(Trim(Edit_Tel.Text),memo_sms_txt.Text)=1 then
label_sms_stact.Caption := 'Send Success+'
else
label_sms_stact.Caption := 'Send Failed'; }
for i:= to ListBox1.Items.Count- do
begin
if Sms_Send(Trim(ListBox1.Items.Strings[i]),memo_sms_txt.Text)= then
label_sms_stact.Caption := 'Send Success+'
else
label_sms_stact.Caption := 'Send Failed';
end;
end;
//------------------------------------------------------------------------------
procedure TSeverFrm.Button2Click(Sender: TObject);
Var
Filename:String;
MyFile:Textfile;
i:Integer;
S:string;
begin
Filename:='D:/a.txt';
AssignFile(Myfile,filename);
try
reset(Myfile);
Except
rewrite(Myfile);
end;
i:=;
while not seekEof(Myfile) do
begin
readln(Myfile,s);
ListBox1.Items.Add(S);
inc(i);
end;
CloseFile(Myfile);
end; end.

服务端

客户端

IdTCPClient1: TIdTCPClient;
IdAntiFreeze1: TIdAntiFreeze;

IdIPWatch1: TIdIPWatch;

unit UnitClient;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, StdCtrls, ExtCtrls, IdIPWatch; type
TRevData=record
Data:string;
Flag:Boolean;
end; TClientFrm = class(TForm)
IdTCPClient1: TIdTCPClient; IdAntiFreeze1: TIdAntiFreeze;
Panel1: TPanel;
Edit_Host: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit_Port: TEdit;
Button_Connet: TButton;
Button_Close: TButton;
Memo1: TMemo;
Button_Send: TButton;
MemoSend: TMemo;
Label3: TLabel;
IdIPWatch1: TIdIPWatch;
procedure Button_ConnetClick(Sender: TObject);
procedure Button_SendClick(Sender: TObject);
procedure Button_CloseClick(Sender: TObject);
private
{ Private declarations }
SendData:string;//沮惠璶э跑祇癳摸ノ挡篶砰舱摸獺
function ClientReadBuffer(IDTCP: TIdTCPClient):string;
procedure ClientWtiteBuffer(IDTCP: TIdTCPClient;strMSG:string);
public
{ Public declarations }
end; var
ClientFrm: TClientFrm; implementation {$R *.dfm} function TClientFrm.ClientReadBuffer(IDTCP: TIdTCPClient):string;
var
ts:TStrings;
stream:TStream;
begin
try
stream := TStringStream.Create(''); //ノㄤ摸Stream钡Μぃ摸计沮
IDTCP.ReadStream(stream);
stream.Position :=;
ts.LoadFromStream(stream);
Result := ts.Text;
finally
stream.Free;
end;
end; procedure TClientFrm.ClientWtiteBuffer(IDTCP: TIdTCPClient;strMSG:string);
var
ts:TStrings;
stream:TStream;
begin
try
stream := TStringStream.Create(strMSG);
IDTCP.WriteStream(stream);
finally
stream.Free;
end;
end; procedure TClientFrm.Button_ConnetClick(Sender: TObject);
var
stream:TStringStream;
begin
IdTCPClient1.Host := Trim(Edit_Host.Text);
IdTCPClient1.Port := StrToInt(Edit_Port.Text);
Memo1.Lines.Add('タ硈钡狝叭竟' + Edit_Host.Text + '...');
with IdTCPClient1 do
begin
try
Connect();
try
Memo1.Lines.Add(ReadLn());
//Memo1.Lines.Add(ClientReadBuffer(IdTCPClient1)+'++');
//Memo1.Lines.LoadFromStream(stream);
Button_Connet.Enabled := False;
Button_Close.Enabled := True;
except
Memo1.Lines.Add('狝叭竟礚臫莱...');
IdTCPClient1.Disconnect();
end;
except
Memo1.Lines.Add('礚猭ミ' + Edit_Host.Text + '硈钡...');
end;
end;
Button_Send.Enabled := True;
end; procedure TClientFrm.Button_SendClick(Sender: TObject);
begin
try
SendData := MemoSend.Text;
IdTCPClient1.WriteLn(SendData+'--Come From'+IdIPWatch1.LocalIP);
Memo1.Lines.Add(IdTCPClient1.ReadLn());
except
IdTCPClient1.Disconnect();
Button_Connet.Enabled := True;
end;
end;
procedure TClientFrm.Button_CloseClick(Sender: TObject);
var
strip:string;
begin
try
strip := IdIPWatch1.LocalIP; //IdTCPClient1.Socket.LocalName;;
IdTCPClient1.WriteLn('SENDMSG诀'+strip+' 笆耞秨硈钡');
//Memo1.Lines.Add(IdTCPClient1.ReadLn()) ;
IdTCPClient1.Disconnect;
Memo1.Lines.Add('狝叭竟硈钡耞秨');
Button_Connet.Enabled := True;
//Button_Send.Enabled := False; except
end;
end; end.

客户端

读取txt

procedure TSeverFrm.Button2Click(Sender: TObject);
Var
Filename:String;
MyFile:Textfile;
i:Integer;
S:string;
begin
Filename:='D:/a.txt';
AssignFile(Myfile,filename);
try
reset(Myfile);
Except
rewrite(Myfile);
end;
i:=0;
while not seekEof(Myfile) do
begin
readln(Myfile,s);
ListBox1.Items.Add(S);
inc(i);
end;
CloseFile(Myfile);
end;

  

短信猫 TIdTCPServer TIdTCPClient的更多相关文章

  1. 在网页程序或Java程序中调用接口实现短信猫收发短信的解决方案

    方案特点: 在网页程序或Java程序中调用接口实现短信猫收发短信的解决方案,简化软件开发流程,减少各应用系统相同模块的重复开发工作,提高系统稳定性和可靠性. 基于HTTP协议的开发接口 使用特点在网页 ...

  2. 基于Socket客户端局域网或广域网内共享同一短信猫收发短信的开发解决方案

    可使同一网络(局域网或广域网)内众多客户端,共享一个短信猫设备短信服务器进行短信收发,短信服务器具备对客户端的管理功能. 下面是某市建设银行采用本短信二次开发平台时实施的系统方案图: 在该方案中,考虑 ...

  3. C# 短信猫(SMS cat) 操作源码开发经验

    我曾经开发的某项目需要使用短信猫模块,要求使用C#编程操作.能独立使用的动态链接库之一就是网上流传的sms.dll,但它的功能较少,不能满足需求,鉴于一时找不到合适的完整代码,我深入研究了短信协议,借 ...

  4. Java应用短信猫

    首先确定短信猫正常连接到主机,并安装SIM卡.先用超级终端测试短息猫能不能用.安装minicom:#sudo apt-get install minicom安装完成后,执行#sudo minicom ...

  5. wavecom短信猫常用AT命令

    wavecom短信猫常用AT命令 一.一般命令 1. AT+CGMI 给出模块厂商的标识. 2. AT+CGMM 获得模块标识.这个命令用来得到支持的频带 (GSM 900,DCS 1800 或PCS ...

  6. CDMA电信短信猫支持189等电信号码可二次开发

    CDMA电信短信猫支持189等电信号码可二次开发 这款短信猫采用法国wavecom Q2358C模块,支持短信猫二次开发,可提供短信猫二次开发包下载测试.提供相关资料文档. 此款CDMA电信短信猫有串 ...

  7. VB短信猫开发包,支持超长短信

    一.短信猫开发包(长短信/异步调用)说明:   短信猫开发包以OCX控件的形式提供,支持Windows平台下常用的开发工具:如VB.VB.net.VC++.Power Builder.C#.DELPH ...

  8. centos6.5 短信猫部署发短信

    本文为在centos下部署短信猫发短信使用,以下为具体环境和步骤说明,欢迎留言! 一.环境说明 服务器:centos6.5 x64 依赖包:lockdev-1.0.1-18.el6.x86_64.rp ...

  9. Linux系统中调用短信猫发送短信(笔记)

    1, 拷贝底层串口依赖的librxtxSerial.so到JDK安装路径cp librxtxSerial.so /usr/java/{0}/jre/lib/{1} # {0}: JDK的基础目录,例如 ...

随机推荐

  1. 【mysql】Blob类型

    来源:http://qgyang.blog.sohu.com/115847378.html 一般在需要存储较大数据时使用Bolb MySql的Bolb四种类型 MySQL中,BLOB是一个二进制大型对 ...

  2. HDU 1159 Common Subsequence --- DP入门之最长公共子序列

    题目链接 基础的最长公共子序列 #include <bits/stdc++.h> using namespace std; ; char c[maxn],d[maxn]; int dp[m ...

  3. August 20th 2016 Week 34th Saturday

    Everything you see exists together in a delicate balance. 你所看到的一切都处于微妙的平衡中. Seeking for balance in l ...

  4. Scanner和BufferedReader

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...

  5. alias命令(使用命令别名)

    通过alias命令可以给一些命令定义别名,如,将长的难记住的命令起一个容易记住的别名,提高工作效率 alias -p 查看已有的别名列表 命名别名格式: alias 新命令名='原命令名 -参数/选项 ...

  6. 数据结构和算法 – 12.高级查找算法(下)

    哈希(散列)技术既是一种存储方法,也是一种查找方法.然而它与线性表.树.图等结构不同的是,前面几种结构,数据元素之间都存在某种逻辑关系,可以用连线图示表示出来,而哈希技术的记录之间不存在什么逻辑关系, ...

  7. 无废话ExtJs 入门教程四[表单:FormPanel]

    无废话ExtJs 入门教程四[表单:FormPanel] extjs技术交流,欢迎加群(201926085) 继上一节内容,我们在窗体里加了个表单.如下所示代码区的第28行位置,items:form. ...

  8. LINQ To DataSet 示例

    如果在项目遇到这样的问题如:DataTable1和DataTable2需要根据一定的规则进行合并成一个DataTable3. 问题1:DataTable1不是读数据库表的结果,而是合成的数据集,因此无 ...

  9. JavaScript - 基本概念

    相等操作符 == 和 != 是先转换再比较 === 和 !== 是直接比较,不经过转换 中文翻译上来说叫做相等和全等.类型转换简单的概括就是高级转低级,比如说布尔字符串转数字,对象取值再转.相等比较有 ...

  10. 使用Visual Studio Code开发AngularJS应用

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:VSC发布之后,尤其最近刚刚更新到0.3之后,社区出现了很多介绍VSC使用的好文章.比 ...