如果我使用类型的变量Int64,它是否适用于所有Windows版本:win95,98,2000,nt,xp,vista,win7?无论什么操作系统是32位还是64位?而且无论他们使用什么CPU?
我只想确定,我的程序将适用于所有Windows版本.
如何将字符串hex转换为int 8的数组?
var hash : string;
x: array[0..19] of int8;
begin
hash := '713BD6D36D4964F4E4F843CB03D118EA5C372FF6';
put_hash_into_x(hash);
end;
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个变量data,变量的类型是:TIdBytes.
变量包含一些用gzip编码的数据.
如何解码这些数据?
如何正确发送数据包到UDP服务器?我正在尝试,但它没有工作,我没有从服务器收到任何东西.
我需要的是发送一个数据包: int64|int|int
并从服务器接收数据包: int|int|int64
怎么做正确?谢谢.
type
Tconnecting = record
a: int64;
b: integer;
c: integer;
end;
Treply_connect = record
a: integer;
b: integer;
c: int64;
end;
var
udp: TIdUDPClient;
send_data: TIdBytes;
received_data: TIdBytes;
i: integer;
packet: Tconnecting;
reply_packet: Treply_connect;
begin
packet.a := 41727101980;
packet.b := 0;
packet.c := RandomRange(1, 9999999);
SetLength(send_data, sizeof(packet));
Move(packet, send_data[0], sizeof(packet));
udp := TIdUDPClient.Create(nil);
try
udp.Host := 'server.com';
udp.Port := 1234;
udp.SendBuffer(send_data);
SetLength(received_data, 0);
i := udp.ReceiveBuffer(received_data, 5000);
Memo1.Lines.Add('Data reiceived! Len:'+IntToStr(Length(received_data))+',data:|'+BytesToString(received_data, 0)+'|');
finally
FreeAndNil(udp);
end;
Run Code Online (Sandbox Code Playgroud) 我有一个表格,白色空间设置为nowrap,列宽度限制使用表格布局固定.这正确地隐藏了Firefox中的长行,但在IE9中,这些行正在包装.
测试用例:
<table border="1" width=200 style="white-space: nowrap; table-layout: fixed;">
<tr>
<td style="overflow: hidden;" width=150>Word with some spaces that isnt working in IE</td>
<td width=50>100/50</td>
</tr>
<tr>
<td style="overflow: hidden;" width=150>LoooooooooOOOOOOOOOoooooooooooooooooongword</td>
<td width=50>550/50</td>
</tr>
<tr>
<td style="overflow: hidden;" width=150>AnotherLoooooooooooonnnnnnnnnnnnnnnnGWord</td>
<td width=50>660/50</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
火狐:

IE 9:

var all: TThreadList = nil;
procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
var list:tlist;
begin
try
list := all.LockList;
try
list.Add(0);
finally
all.UnlockList;
end;
except
end;
end;
Run Code Online (Sandbox Code Playgroud)
telnet 127.0.0.1 1234
为什么它会被访问违规?
cs.Acquire;
try
AContext.Connection.Socket.Write(packet);
finally
cs.Release;
end;
Run Code Online (Sandbox Code Playgroud)
要么
EnterCriticalSection(cs);
AContext.Connection.Socket.Write(packet);
LeaveCriticalSection(cs);
Run Code Online (Sandbox Code Playgroud)
我试图在线程中将我的数据包发送到服务器,但我有20个线程,它也将数据发送到同一个连接套接字.我尝试使用Critical Section或Mutex,它们都不起作用,我收到所有线程发送时的垃圾.
这都是关于我之前的问题
数据包看起来像这样:
LengthData
0000000010HelloWorld
服务器接收数据:
ReadBytes(10);
len := (Then remove zeros from begining);
ReadBytes(len); // data.
Run Code Online (Sandbox Code Playgroud)
有时我会在ReadBytes(10)中收到垃圾,它是长度+数据的混合,例如:"10Hellowor"
如果我只使用一个线程将数据发送到服务器,那么每次都可以正常工作.如果发送了很多线程,那么一切都会出错.
有时这个函数会锁定我的程序,它会冻结,直到我关闭它.这有什么不对?
function del_from_list(id:string):boolean;
var i : integer;
begin
Result := True;
try
with global_list.LockList do
begin
for i:=0 to Count-1 do
begin
if Tthread_list(Items[i]).id = id then
begin
Delete(i);
break;
end;
end;
end;
finally
global_list.UnlockList;
end;
end;
Run Code Online (Sandbox Code Playgroud)
班级
Tthread_list = class
public
id : string;
constructor Create(const id: string);
end;
Run Code Online (Sandbox Code Playgroud)
我正在添加到列表中:
global_list.Add(Tthread_list.Create('xxx'));
Run Code Online (Sandbox Code Playgroud)
全局列表是一个全局变量
var global_list : TThreadList = nil;
Run Code Online (Sandbox Code Playgroud)