发送数据函数代码
function TMySocket.SendUDPData(ARemoteIP: string; ARemotePort: Word; var ABuffer;
ABufferCount: integer): Boolean;
var
FRemotAddr: TSockAddrIn;
begin
Result := false;
try
FRemotAddr.SIn_Family := AF_INET;
FRemotAddr.sin_addr.s_addr := inet_addr(pansichar(ARemoteIP));
FRemotAddr.sin_port := htons(ARemotePort);
if sendto(FMainSocket, ABuffer, ABufferCount, 0, FRemotAddr, SizeOf(FRemotAddr)) <> ABufferCount then
begin
Exit;
end;
except
end;
inc(SendCount);
inc(SendSize, ABufferCount);
Result := true;
end;