大型C/S管理系统为何经常死机? (200分)

  • 主题发起人 主题发起人 itren
  • 开始时间 开始时间
to 老赵
抓屏只是偶尔的进行,而且针对型比较强,但是死机的情况在没有抓屏时就发生了!
所以很是奇怪。
to 小令
Udp 是不稳定,这我也是知道的,但是相对比较节省资源,而且系统传递的消息
可靠性要求不是很高。
我觉得并不是换了 ServerSocket 就万事大吉了吧!?

希望大家踊跃发言,是个很棘手的问题!

 
来自:fql, 时间:2002-1-10 13:41:00, ID:847568
我建议你最好用一个中介服务器,因为c/s的性能受客户机
多少的影象(一般c/s模式的客户机应在200台以内)
你的系统大大的超过了范围,因此系统不稳定
***************************************************
不是这个的问题吧!!!serversocket 就是连1000台都没有问题吧!
网络游戏里聊天系统,1台服务器上就有上千人同时在线的!!!!!!
具体什么问题我也不清楚!!!!
 
检查
1) 服务器消耗资源的任务,
2) 服务器硬件(内存,网卡)
 
>> 抓屏只是偶尔的进行,而且针对型比较强,但是死机的情况在没有抓屏时就发生了!
>> 所以很是奇怪。

我觉得不奇怪.假如资源没有释放,那末"偶尔"到一定程度就会"必然"了.
你可以这样,把抓屏停掉,看看如何.否则,也可能是其他地方消耗资源.
我还是认为资源耗尽造成的死机.
还是用memproof之类的监视一下你的程序看看吧.
 
to 老赵
不好意思昨天出差了,没来得及看贴子!
老兄,死机的状况是刚开始就死机,大概是这样:所有的客户机都运行着,所以每隔
3秒要向服务器传递 消息,以表示在线,会不会是这个问题啊,服务器要处理的数据
:250 * 每个客户端消息的字节, 并且是三秒之内,不然下次的消息又发送过来。当
然网卡似乎可以缓冲处理了,而且 UDP 顶多是丢失而已,无确认信息,对客户机没有影响
 
to itren
我也正在做一个考试系统,适用于学校机房,500个用户,在考试时服务器需不断的接收
客户端发来的数据(如考试时间、答案等,我不想将这些敏感数据存在客户端本地),所
以我一直都在考虑用TCP还是UDP,如果用UDP的话服务器肯定需返回一个确认报文已确保
数据收到,用TCP的话我觉的重点在建立连接的时间和连接的方式,是至始至终的一直保持
连接还是传完数据就马上断开,要传的时候再连,如果这样的话,建立连接会不会太耗时
一直保持连接的方式可取吗

to xxhsh
serversocket 1000台都没有问题?!是真的吗,你试过吗,我的SERVER可是NT吖
 
to 橡皮巴
现在的网络游戏火爆!!!一台服务器上有上千个玩家,就是用socket的阿!!!
 
to xxhsh :
从技术讲 socket 的确是很强壮的,但是服务器的负荷也是个问题,所以服务器
就产生了,我觉得是规模适度。
to 橡皮巴
如果单纯是毕设水平的话,哪一种都无所谓了。
如果要实用一点的话,本人觉得 或者是自定义的带确认的 UDP ,或者是
队列的 Socket 连接,尽量减少创建 释放 的出现,能用则用,不用就挂起来。
to 老赵
老赵再来看一下。昨天我试验了一下,单纯是抓屏操作,似乎客户机同时
开了 15 个 IE 窗口之后,服务器就有点迟钝,好像就是类死机。(就是抓屏没抓过来)
窗体 Showmodal 之后,后面的窗体按道理不应该执行了吧。我是在 Timer 中写的
存盘程序。

 
itren:
如果你用的是DELPHI自带的NMUDP,有可能是这个控件的BUG造成的,
比如造成学生机无法重启,关机等,(好像只在98某个版本会出现这个情况)
而且在CLOSEQUERY时把UDP.free掉也没用,还造成了系统死锁,
后来我找到了NMUDP的源代码,更新了一下,就没问题了。你也可以试试看。。
 
to Forss
FastNet 5.63我用的是.
 
我用的也是5.63 只不过修改了源代码以后的。
 
一般c/s模式的客户机应在200台以内
 
itren的情况不是C/S模式啦。。。
 
to Forss
不会影响这么大吧!当然这是脱管的一部分原因。(:能否告知如何得到新的源码?
我们的问题是,服务器端死机,补充一点:一个窗体的 2 个 timer 会冲突吗?
 
源代码是我从离线数据里搜来的,:)
,用了两个TIMER,为什么不用线程呢?
{
// Version:5.6.3 Build:1091 Date:1/31/00 //
////////////////////////////////////////////////////////////////////////////
// //
// Copyright ?1997-1999, NetMasters, L.L.C - All rights reserved worldwide. //
// Portions may be Copyright ?Borland International, Inc. //
// //
// Unit Name: MYNMUDP //
// //
// DESCRIPTION:Internet UDP Component //
// + Aug-9-98 Version 4.1 -- KNA //
// //
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY //
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE //
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR //
// PURPOSE. //
// //
////////////////////////////////////////////////////////////////////////////
}
// Revision History
// 01 04 00 - KNA - Non ASYNC messages passed on
// 07 12 99 - KNA - Resolve Host converted to Wait
// 07 02 98 - KNA - Port of sender available
// 01 27 98 - KNA - Final release Ver 4.00 VCLS
//

{$IFDEF VER100}
{$DEFINE NMF3}
{$ENDIF}
{$IFDEF VER110}
{$DEFINE NMF3}
{$ENDIF}
{$IFDEF VER120}
{$DEFINE NMF3}
{$ENDIF}
{$IFDEF VER125}
{$DEFINE NMF3}
{$ENDIF}

unit MYNMUDP;

interface

uses
Winsock, Classes, Sysutils, WinTypes, Messages, Forms;
{$IFDEF VER110}
{$OBJEXPORTALL On}
{$ENDIF}
{$IFDEF VER120}
{$OBJEXPORTALL On}
{$ENDIF}
{$IFDEF VER125}
{$OBJEXPORTALL On}
{$ENDIF}

const
/////////////////////////////////////////////////////////////////////////////////
DataPackSize = 65535 ; //////lsyx

//修改此数即可改变每次传送数据包大小;





// CompName ='TMYNMUDP';

// Major_Version ='4';
// Minor_Version ='02';
// Date_Version ='012798';

{ Levels for reporting Status Messages}
Status_None = 0;
Status_Informational = 1;
Status_Basic = 2;
Status_Routines = 4;
Status_Debug = 8;
Status_Trace = 16;


WM_ASYNCHRONOUSPROCESS = WM_USER + 101; {Message number for asynchronous socket messages}

const {protocol}
Const_cmd_true = 'TRUE';

{$IFDEF NMF3}
resourcestring
{$ELSE}
const
{$ENDIF}
{ Cons_Palette_Inet = 'Internet';
Cons_Msg_Wsk = 'Initializing Winsock';
Cons_Msg_Lkp = 'Host Lookup Canceled';
Cons_Msg_Data = 'Sending Data';
Cons_Msg_InvStrm = 'Invalid stream';
Cons_Msg_Echk = 'Checking Error In Error Manager';
Cons_Msg_Eno = 'Unknown Error No. ';
Cons_Msg_ELkp = 'Looking Up Error Message';
Cons_Err_Addr = 'Null Remote Address';
Cons_Err_Buffer = 'Invalid buffer'; }

Cons_Palette_Inet = 'MYVCL';
Cons_Msg_Wsk = '正在初始化 Winsock';
Cons_Msg_Lkp = '主机查找已取消';
Cons_Msg_Data = '正在传送数据';
Cons_Msg_InvStrm = '无效的流';
Cons_Msg_Echk = '正在错误管理器中检测错误';
Cons_Msg_Eno = '未知错误代号 ';
Cons_Msg_ELkp = '正在查找错误信息';
Cons_Err_Addr = '空的远程地址';
Cons_Err_Buffer = '无效的缓冲区';

type

UDPSockError = class(Exception);

{Event Handlers}

TOnErrorEvent = procedure(Sender: TComponent; errno: word; Errmsg: string) of object;
TOnStatus = procedure(Sender: TComponent; status: string) of object;
TOnReceive = procedure(Sender: TComponent; NumberBytes: Integer; FromIP: string; Port: integer) of object;
THandlerEvent = procedure(var handled: boolean) of object;
TBuffInvalid = procedure(var handled: boolean; var Buff: array of char; var length: integer) of object;
TStreamInvalid = procedure(var handled: boolean; Stream: TStream) of object;

TMYNMUDP = class(TComponent)
private
IBuff: array[0..DataPackSize] of char; ///////lsyx
IBuffSize: integer;
FRemoteHost: string;
FRemotePort: integer;
FLocalPort: integer; {Port at server to connect to}
RemoteAddress, RemoteAddress2: TSockAddr; {Address of remote host}
FSocketWindow: hwnd;
Wait_Flag: boolean; {Flag to indicate if synchronous request completed or not}
RemoteHostS: PHostEnt; {Entity to store remote host linfo from a Hostname request}
Canceled: boolean; {Flag to indicate request cancelled}
Succeed: boolean; {Flag for indicating if synchronous request succeded}
MyWSAData: TWSADATA; {Socket Information}
FOnStatus: TOnStatus; {} {Event handler on a status change}
FReportLevel: integer; {Reporting Level}
_status: string; {Current status}
_ProcMsg: boolean; {Flag to supress or enable socket message processing}
FLastErrorno: integer; {The last error Encountered}
FOnErrorEvent: TOnErrorEvent; {} {Event handler for error nitification}
FOnDataReceived: TOnReceive;
FOnDataSend: TNotifyEvent;
FOnInvalidHost: THandlerEvent;
FOnStreamInvalid: TStreamInvalid;
FOnBufferInvalid: TBuffInvalid;
procedure WndProc(var message: TMessage);
procedure ResolveRemoteHost;
procedure SetLocalPort(NewLocalPort: integer);
procedure ProcessIncomingdata;
protected
procedure StatusMessage(Level: byte; value: string);
function ErrorManager(ignore: word): string;
function SocketErrorStr(Errno: word): string;
procedure Wait;
public
EventHandle : THandle;
ThisSocket: TSocket; {The socket number of the Powersocket}
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Loaded; override;
procedure Cancel;
procedure SendStream(DataStream: TStream);
procedure SendBuffer(Buff: array of char; length: integer);
procedure ReadStream(DataStream: TStream);
procedure ReadBuffer(var Buff: array of char; var length: integer);
published
property RemoteHost: string read FRemoteHost write FRemoteHost; {Host Nmae or IP of remote host}
property RemotePort: integer read FRemotePort write FRemotePort; {Port of remote host}
property LocalPort: integer read FLocalPort write SetLocalPort; {Port of remote host}
property ReportLevel: integer read FReportLevel write FReportLevel;
property OnDataReceived: TOnReceive read FOnDataReceived write FOnDataReceived;
property OnDataSend: TNotifyEvent read FOnDataSend write FOnDataSend;
property OnStatus: TOnStatus read FOnStatus write FOnStatus;
property OnInvalidHost: THandlerEvent read FOnInvalidHost write FOnInvalidHost;
property OnStreamInvalid: TStreamInvalid read FOnStreamInvalid write FOnStreamInvalid;
property OnBufferInvalid: TBuffInvalid read FOnBufferInvalid write FOnBufferInvalid;
end; {_ TMYNMUDP = class(TComponent) _}

procedure Register;

implementation

uses NMConst;

procedure Register;
begin
RegisterComponents(Cons_Palette_Inet, [TMYNMUDP]);
end; {_ procedure register; _}

procedure WaitforSync(Handle: THandle);
begin
repeat
if MsgWaitForMultipleObjects(1, Handle, False,
INFINITE, QS_ALLINPUT)
= WAIT_OBJECT_0 + 1
then Application.ProcessMessages
else BREAK;
until True = False;
end; {_WaitforSync_}

procedure TMYNMUDP.Cancel;
begin
StatusMessage(Status_Debug, sPSk_Cons_msg_Cancel); {Status Message}
Canceled := True; {Set Cancelled to true}
SetEvent(EventHandle);
end;


constructor TMYNMUDP.Create(AOwner: TComponent);

begin
inherited create(AOwner);
_ProcMsg := FALSE; {Inhibit Event processing for socket}
{ Initialize memory }
getmem(RemoteHostS, MAXGETHOSTSTRUCT); {Initialize memory for host address structure}
FSocketWindow := AllocateHWnd(WndProc); {Create Window handle to receive message notification}
{ Set Variables }
FreportLevel := Status_Informational; {Set Default Reporting Level}
Canceled := FALSE; {Cancelled flag off}
EventHandle := CreateEvent(nil, True, False, '');
StatusMessage(Status_debug, Cons_Msg_Wsk); {Status Message}
if WSAStartUp($0101, MyWSADATA) = 0 then
try
ThisSocket := Socket(AF_INET, SOCK_DGRAM, 0); {Get a new socket}
if ThisSocket = TSocket(INVALID_SOCKET) then
ErrorManager(WSAEWOULDBLOCK); {If error handle error}
setsockopt(ThisSocket, SOL_SOCKET, SO_DONTLINGER, Const_cmd_true, 4);
except
WSACleanup; {If error Cleanup}
raise; {Pass exception to calling function}
end {_ try _}
else {_ NOT if WSAStartUp($0101, MyWSADATA) = 0 then _}
ErrorManager(WSAEWOULDBLOCK); {Handle Statrtup error}
_ProcMsg := true;
end; {_ constructor TMYNMUDP.Create(AOwner: TComponent); _}

{*******************************************************************************************
Destroy Power Socket
********************************************************************************************}

destructor TMYNMUDP.Destroy;
begin
{cancel; }
freemem(RemoteHostS, MAXGETHOSTSTRUCT); {Free memory for fetching Host Entity}
DeAllocateHWnd(FSocketWindow); {Release window handle for Winsock messages}
CloseHandle(EventHandle);
WSACleanUp; {Clean up Winsock}
inherited destroy; {Do inherited destroy method}
end; {_ destructor TMYNMUDP.Destroy; _}

procedure TMYNMUDP.SetLocalPort(NewLocalPort: integer);
begin
if ThisSocket <> 0 then closesocket(ThisSocket);
WSAcleanup;
if WSAStartUp($0101, MyWSADATA) = 0 then
try
ThisSocket := Socket(AF_INET, SOCK_DGRAM, 0); {Get a new socket}
if ThisSocket = TSocket(INVALID_SOCKET) then
ErrorManager(WSAEWOULDBLOCK); {If error handle error}
except
WSACleanup; {If error Cleanup}
raise; {Pass exception to calling function}
end {_ try _}
else {_ NOT if WSAStartUp($0101, MyWSADATA) = 0 then _}
ErrorManager(WSAEWOULDBLOCK); {Handle Statrtup error}
FLocalPort := NewLocalPort;
Loaded;
end; {_ procedure TMYNMUDP.SetLocalPort(NewLocalPort: integer); _}


procedure TMYNMUDP.Loaded;
var
buf: array[0..17] of char;
begin
if not (csDesigning in ComponentState) then
begin
RemoteAddress2.sin_addr.S_addr := Inet_Addr(strpcopy(buf, '0.0.0.0'));
RemoteAddress2.sin_family := AF_INET; {Family = Internet address}
RemoteAddress2.sin_port := htons(FLocalPort); {Set port to given port}
wait_flag := FALSE; {Set flag to wait}
{Bind Socket to given address}
WinSock.bind(ThisSocket, RemoteAddress2, SizeOf(RemoteAddress2));
{Direct reply message to WM_WAITFORRESPONSE handler}
WSAAsyncselect(ThisSocket, FSocketWindow, WM_ASYNCHRONOUSPROCESS, FD_READ);
end; {_ if not (csDesigning in ComponentState) then _}
end; {_ procedure TMYNMUDP.Loaded; _}

{*******************************************************************************************
Resolve IP Address of Remote Host
********************************************************************************************}

procedure TMYNMUDP.ResolveRemoteHost;
var
BUF: array[0..127] of char;
CTry: integer;
Handled: boolean;
begin
remoteaddress.sin_addr.S_addr := Inet_Addr(strpcopy(buf, FRemoteHost));
if remoteaddress.sin_addr.S_addr = SOCKET_ERROR then
{If given name not an IP address already}
begin
CTry := 0;
repeat
Wait_Flag := FALSE; {Reset flag indicating wait over}
{Resolve IP address}
wsaasyncgethostbyname(FSocketWindow, WM_ASYNCHRONOUSPROCESS, Buf, PChar(remotehostS), MAXGETHOSTSTRUCT);
repeat
Wait;
until Wait_Flag or Canceled; {Till host name resolved, Timed out or cancelled}
{Handle errors}
if Canceled then
raise UDPSockError.create(Cons_Msg_Lkp);
if Succeed = FALSE then
begin
if CTry < 1 then
begin
CTry := CTry + 1;
Handled := FALSE;
if assigned(FOnInvalidHost) then FOnInvalidHost(Handled);
if not handled then UDPSockError.create(Cons_Msg_Lkp);
end {_ if CTry < 1 then _}
else {_ NOT if CTry < 1 then _} raise UDPSockError.create(Cons_Msg_Lkp);
end {_ if Succeed = FALSE then _}
else {_ NOT if Succeed = FALSE then _}
{Fill up remote host information with retreived results}
with RemoteAddress.sin_addr.S_un_b do
begin
s_b1 := remotehostS.h_addr_list^[0];
s_b2 := remotehostS.h_addr_list^[1];
s_b3 := remotehostS.h_addr_list^[2];
s_b4 := remotehostS.h_addr_list^[3];
end; {_ with RemoteAddress.sin_addr.S_un_b do _}
until Succeed = true;
end; {_ if remoteaddress.sin_addr.S_addr = SOCKET_ERROR then _}
end; {_ procedure TMYNMUDP.ResolveRemoteHost; _}

procedure TMYNMUDP.SendStream(DataStream: TStream);
var Ctry, i: integer;
BUf: array[0..DataPackSize] of char; //////lsyx
Handled: boolean;
begin
CTry := 0;
while DataStream.size = 0 do
if CTry > 0 then raise Exception.create(Cons_Msg_InvStrm)
else {_ NOT if CTry > 0 then raise Exception.create(Cons_Msg_InvStrm) _}
if not assigned(FOnStreamInvalid) then raise Exception.create(Cons_Msg_InvStrm)
else {_ NOT if not assigned(FOnStreamInvalid) then raise Exception.create(Cons_Msg_InvStrm) _}
begin
Handled := FALSE;
FOnStreamInvalid(Handled, DataStream);
if not Handled then raise Exception.create(Cons_Msg_InvStrm)
else {_ NOT if not Handled then raise Exception.create(Cons_Msg_InvStrm) _} CTry := CTry + 1;
end; {_ NOT if not assigned(FOnStreamInvalid) then raise Exception.create(Cons_Msg_InvStrm) _}
Canceled := FALSE; {Turn Canceled off}
ResolveRemoteHost; {Resolve the IP address of remote host}
if RemoteAddress.sin_addr.S_addr = 0 then
raise UDPSockError.create(Cons_Err_Addr); {If Resolving failed raise exception}
StatusMessage(Status_Basic, Cons_Msg_Data); {Inform status}
RemoteAddress.sin_family := AF_INET; {Make connected true}
{$R-}
RemoteAddress.sin_port := htons(FRemotePort); {If no proxy get port from Port property}
{$R+}
i := SizeOf(RemoteAddress); {i := size of remoteaddress structure}
{Connect to remote host}
DataStream.position := 0;
DataStream.ReadBuffer(Buf, DataStream.size);
WinSock.SendTo(ThisSocket, Buf, DataStream.size, 0, RemoteAddress, i);
if assigned(FOnDataSend) then FOnDataSend(self);
end; {_ procedure TMYNMUDP.SendStream(DataStream: TStream); _}

procedure TMYNMUDP.SendBuffer(Buff: array of char; length: integer);
var Ctry, i: integer;
Handled: boolean;
begin
CTry := 0;
while length = 0 do
if CTry > 0 then raise Exception.create(Cons_Err_Buffer)
else {_ NOT if CTry > 0 then raise Exception.create(Cons_Err_Buffer) _}
if not assigned(FOnBufferInvalid) then raise Exception.create(Cons_Err_Buffer)
else {_ NOT if not assigned(FOnBufferInvalid) then raise Exception.create(Cons_Err_Buffer) _}
begin
Handled := FALSE;
FOnBufferInvalid(Handled, Buff, length);
if not Handled then raise Exception.create(Cons_Err_Buffer)
else {_ NOT if not Handled then raise Exception.create(Cons_Err_Buffer) _} CTry := CTry + 1;
end; {_ NOT if not assigned(FOnBufferInvalid) then raise Exception.create(Cons_Err_Buffer) _}
Canceled := FALSE; {Turn Canceled off}
ResolveRemoteHost; {Resolve the IP address of remote host}
if RemoteAddress.sin_addr.S_addr = 0 then
raise UDPSockError.create(Cons_Err_Addr); {If Resolving failed raise exception}
StatusMessage(Status_Basic, Cons_Msg_Data); {Inform status}
RemoteAddress.sin_family := AF_INET; {Make connected true}
{$R-}
RemoteAddress.sin_port := htons(FRemotePort); {If no proxy get port from Port property}
{$R+}
i := SizeOf(RemoteAddress); {i := size of remoteaddress structure}
WinSock.SendTo(ThisSocket, Buff, length, 0, RemoteAddress, i);
if assigned(FOnDataSend) then FOnDataSend(self);
end; {_ procedure TMYNMUDP.SendBuffer(Buff: array of char; length: integer); _}
{*******************************************************************************************
Handle Power socket error
********************************************************************************************}

function TMYNMUDP.ErrorManager(ignore: word): string;
var
slasterror: string;
begin
StatusMessage(STATUS_TRACE, Cons_Msg_Echk); {Report Status}
FLastErrorno := wsagetlasterror; {Set last error}
if (FLastErrorno and ignore) <> ignore then
{If the error is not the error to be ignored}
begin
slasterror := SocketErrorStr(FLastErrorno); {Get the description string for error}
if assigned(fonerrorevent) then
{If error handler present excecute it}
FOnerrorEvent(Self, FLastErrorno, slasterror);
raise UDPSockError.create(slasterror); {Raise exception}
end; {_ if (FLastErrorno and ignore) <> ignore then _}
result := slasterror; {return error string}
end; {_ function TMYNMUDP.ErrorManager(ignore: word): string; _}

{*******************************************************************************************
Return Error Message Corresponding To Error number
********************************************************************************************}

function TMYNMUDP.SocketErrorStr(ErrNo: word): string;
begin
if ErrNo <> 0 then
{If error exits}
begin
(*for x := 0 to 50 do {Get error string}
if winsockmessage[x].errorcode = errno then
Result := inttostr( winsockmessage[x].errorcode ) + ':' + winsockmessage[x].text; *)
if Result = '' then {If not found say unknown error}
Result := Cons_Msg_Eno + IntToStr(ErrNo);
end; {_ if ErrNo <> 0 then _}
StatusMessage(Status_DEBUG, Cons_Msg_ELkp + result); {Status message}
end; {_ function TMYNMUDP.SocketErrorStr(ErrNo: word): string; _}

{*******************************************************************************************
Output a Status message: depends on current Reporting Level
********************************************************************************************}

procedure TMYNMUDP.StatusMessage(Level: byte; value: string);
begin
if level <= FReportLevel then
{If level of error less than present report level}
begin
_status := value; {Set status to vale of error}
if assigned(FOnStatus) then
FOnStatus(self, _status); {If Status handler present excecute it}
end; {_ if level <= FReportLevel then _}
end; {_ procedure TMYNMUDP.StatusMessage(Level: byte; value: string); _}

{*******************************************************************************************
Socket Message handler
********************************************************************************************}

procedure TMYNMUDP.WndProc(var message: TMessage);
begin
if _ProcMsg then {If Processing of messages enabled}
with message do
if msg = WM_ASYNCHRONOUSPROCESS then
begin
if lparamLo = FD_Read then
ProcessIncomingdata
else {_ NOT if lparamLo = FD_Read then _}
begin
wait_flag := TRUE;
if lparamhi > 0 then
{If no error}
Succeed := FALSE {Succed flag not set}
else {_ NOT if lparamhi > 0 then _}
Succeed := TRUE;
end; {_ NOT if lparamLo = FD_Read then _}
SetEvent(EventHandle);
end {_ if msg = WM_ASYNCHRONOUSPROCESS then _}
else
Result := DefWindowProc(FSocketWindow, Msg, wParam, lParam);
end; {_ procedure TMYNMUDP.WndProc(var message: TMessage); _}


procedure TMYNMUDP.ProcessIncomingdata;
var
From: TSockAddr;
i: integer;
s1: string;
p1: u_short;

begin
i := sizeof(From);
IBuffSize := Winsock.RecvFrom(ThisSocket, IBuff, DataPackSize, 0, From, i); /////lsyx
if assigned(FOnDataReceived) then
begin
s1 := format('%d.%d.%d.%d', [ord(From.sin_addr.S_un_b.S_b1), ord(From.sin_addr.S_un_b.S_b2), ord(From.sin_addr.S_un_b.S_b3), ord(From.sin_addr.S_un_b.S_b4)]);
p1 := ntohs(From.sin_port);
FOnDataReceived(self, IBuffSize, s1, p1);
end; {_ if assigned(FOnDataReceived) then _}
end; {_ procedure TMYNMUDP.ProcessIncomingdata; _}

procedure TMYNMUDP.ReadStream(DataStream: TStream);

begin
DataStream.WriteBuffer(IBuff, IBuffSize);
DataStream.position := 0;
end; {_ procedure TMYNMUDP.ReadStream(DataStream: TStream); _}

procedure TMYNMUDP.Wait;
begin
WaitforSync(EventHandle);
ResetEvent(EventHandle);
end;

procedure TMYNMUDP.ReadBuffer(var Buff: array of char; var length: integer);

begin
Move(IBuff, Buff, IBuffSize);
length := IBuffSize;
end; {_ procedure TMYNMUDP.ReadBuffer(var Buff: array of char; var length: integer); _}


end.
 
to Forss:
因为是接手别人的工作,再加上以前没有问题,所以懒得改!所以没有用线程!
现在就出问题了。
谢谢你的源码,我先试一下,若解决了,更好!当然这或许仅仅是一种可能
并不是造成死记的原因,是个潜伏的问题。(要不然,以前的系统怎么回没有问题呢?

to All:
大家集思广益,加油加油!
 
没有人来了吗
 
itren:
这个问题被搁了好久了吧,,:) 今天偶尔翻了翻离线数据发现一个贴子里写的可能
和你遇到的情况有关,如果你用了LISTVIEW的CustomDrawItem这个过程,
会引起资源严重丢失,最后死机。
这可能是一个不小的BUG。
开始不会发生,只要你多刷新几次其中内容,就会减小一些资源,就是说,用过的内存
不能释放,最后是只能以出现蓝面告终!
可以在资源管理器的关于中查看资源的多少!
该贴来源:lid=574729 希望对你有所帮助.
 
谢了!
继续!!
 
最新进展:
上个月又做了一个客户: 是 600 台机器的大机房 用三个门禁,平均 200/个 。
不死机,只不过偶尔脱管:(客户机与服务器通讯 UDP 丢包!)
现在的问题是:
影响局域网内的服务器处理能力的因素有哪些? 我估计有如下几个方面:
网卡;服务器内存,Cpu ,硬盘,(读写速度),
总而言之:网络环境 软件环境

大家有什么高见!!!!!

 
后退
顶部