我对其中的BUF有些不理解,他到底是什么东西!
解决方案 »
- listbox的使用问题,菜鸟求问!
- 用IndyFTP如何将一个文件移动到指定的文件夹?
- [Warning] Unit1.pas(394): Unsafe type 'PChar' 望高手指点
- 如何挂起/唤醒其它程序?
- 关于控件数量的问题,急用!
- 图层信息的纪录!
- 装有DELPHI6 SQL SERVER2000客户端系统 win2000 Pro 的平台(单机)能开发SQL SERVER2000 数据库程序吗?
- Delphi中Midas技术
- 在数据库中定义的DateTime类型字段(SQL Server),我如何只让DBGrad自动显示年和月!
- 关于用ClientSocket和ServerSocket构建三层应用
- delphi 如何将源程序编译成可执行程序
- 如何做一个类似kele8那样的情景聊天室?各位高手,看看呀,给点意见
比如说你要传一个学生的信息
type
strudent =record
name : string[20];
age: integer;
number: string[10];
end;
这样不需要将name,age,number等一个一个的发送出去
而是可以将一个数据包直接发送出去
type
PUdpPak = ^UdpPak;
UdpPak=record
Time: TDateTime;
ErrClient: String[20];
AppName: String[50];
Msg: String[255];
Url: String[255];
Popup: Boolean;
end;function TAlertServer.AlarmInLan(Time: TDateTime;App,ErrClient,Msg,Url: String;Popup: Boolean=False): integer;
var
Upack: PUdpPak;
begin
New(Upack);
Upack^.Time := Now;
Upack^.AppName := App;
Upack^.ErrClient := ErrClient;
Upack^.Msg := Msg;
Upack^.Url := Url;
Upack^.Popup := Popup; try
IdUDPClient1.Host := '192.168.0.255';
IdUDPClient1.SendBuffer(Upack^,sizeof(UdpPak));
finally
Dispose(Upack);
end; Result := 1;end;
这是从我自己地程序里面截下来的,参考参考吧
TCustomWinSocket.SendBufWrites Count bytes to the socket connection from the Buf parameter.function SendBuf(var Buf; Count: Integer): Integer;DescriptionUse SendBuf to write to the socket connection. Call this method from the OnSocketEvent event handler of a Windows socket object or in the OnWrite or OnClientWrite event handler of a socket component. Alternately, Use SendBuf to write when a connection is first formed when the socket does not expect notification that the socket on the other end of the connection is expecting to read.For non-blocking sockets, the data is sent to the WinSock DLL which has it's own internal buffers. If the WinSock can accept additional data, SendBuf returns immediately with the number of bytes queued. If the WinSock internal buffer space is not able to accept the buffer being sent, SendBuf returns -1 and no data is queued at all. In this case, wait a bit for the WinSock to have a chance to send out already-queued data; then try again.For blocking sockets, SendBuf returns the number of bytes actually written. If an error occurs while writing to the connection, SendBuf terminates the connection and raises an ESocketError exception.