F
flyerer1
Unregistered / Unconfirmed
GUEST, unregistred user!
客户端向服务端发送可以.
服务端向客户端发送出现'' is not valid integer value.
以下是发送(Button)的code.
AcceptSock:Array[0..MAX_ACCEPT] OF Tsocket;
FSockAccept : Array[0..MAX_ACCEPT] OF TSockAddrIn;
AcceptSockFlag: Array[0..MAX_ACCEPT] OF boolean;
type
TUDPaction = packed record
opcode:byte; //操作码
index:word; //序列号
Command:byte; //命令字
data:array[0..(DATA_LENGTH-1)] of char; //数据
end;
procedure TFormTCPUDP.BtnSendClick(Sender: TObject);
var SEND_PACKAGE : TUDPaction;
i:integer;
begin
// CmbSendto.Text :='套接口:1 地址:127.0.0.1 端口:4760';
i:=pos(' ',CmbSendto.Text);
if i>0 then
begin
i:=strtoint(MidStr(CmbSendTo.Text,8,i-8));
sendto(AcceptSock, SEND_PACKAGE,sizeof(SEND_PACKAGE), 0, FSockAccept, sizeof(FSockAccept));
// 函数原型:sendto(s:integer;var Buf;len :integer; flags:integer;var addrto: sockaddr_in;tolen:integer)
end;
服务端向客户端发送出现'' is not valid integer value.
以下是发送(Button)的code.
AcceptSock:Array[0..MAX_ACCEPT] OF Tsocket;
FSockAccept : Array[0..MAX_ACCEPT] OF TSockAddrIn;
AcceptSockFlag: Array[0..MAX_ACCEPT] OF boolean;
type
TUDPaction = packed record
opcode:byte; //操作码
index:word; //序列号
Command:byte; //命令字
data:array[0..(DATA_LENGTH-1)] of char; //数据
end;
procedure TFormTCPUDP.BtnSendClick(Sender: TObject);
var SEND_PACKAGE : TUDPaction;
i:integer;
begin
// CmbSendto.Text :='套接口:1 地址:127.0.0.1 端口:4760';
i:=pos(' ',CmbSendto.Text);
if i>0 then
begin
i:=strtoint(MidStr(CmbSendTo.Text,8,i-8));
sendto(AcceptSock, SEND_PACKAGE,sizeof(SEND_PACKAGE), 0, FSockAccept, sizeof(FSockAccept));
// 函数原型:sendto(s:integer;var Buf;len :integer; flags:integer;var addrto: sockaddr_in;tolen:integer)
end;