최신 Raspbian이로드 된 Ribberry PI에서 Indy 10.6 tcpserver를 사용하여 새 시스템을 설정하고 있습니다. 나는 sudo가있는 터미널 bash 스크립트를 통해 GUI 데스크탑에서 응용 프로그램을 실행 중입니다. 클라이언트가 연결될 때까지 모든 것이 잘 작동하고 연결이 끊어지면 Gtk-WARNINGs가 나오고 Gtk-CRITICALs가 나오고 그 이유를 모르겠습니다. 여기 내 코드는 한 번에 하나 개의 클라이언트 연결이 다음 서버를 비활성화 할 수 있으며 각 연결 완료 후 다시 시작이야 :Indy 10.6 관리자 권한이있는 Linux 시스템에서 tcpserver를 사용하면 클라이언트 연결이 끊어지면 Gtk-WARNING이 발생합니다.
Procedure TFK20Elevator.ASpeedBtn1Click(Sender: TObject);
Begin //start the server
Server.Active := False;
Server.Bindings.Clear;
Server.Bindings.Add.IPVersion := Id_IPv4;
Server.Bindings.Add.IP := LIP;
Server.Bindings.Add.Port := DefPort + StrToIntDef(UnitID, 0);
Try
Server.Active := True;
Except
On E: Exception Do
Memo1.Lines.Add(E.Message);
End;
If Not Server.Active Then
Exit;
ASpeedBtn1.Enabled := False;
ASpeedBtn2.Enabled := True;
AStatus1.SimpleText := 'Server bound to ' + LIP + ':' + IntToStr(DefPort + StrToIntDef(UnitID, 0));
End;
Procedure TFK20Elevator.ServerConnect(AContext: TIdContext);
Begin
If Connected Then
Begin
Abort();
Exit;
End;
AStatus1.SimpleText := 'Connecting to> ' + AContext.Binding.PeerIP + ' - Authenticating...';
Memo1.Lines.Clear;
Manager := False;
EncDecSIdx := 1;
RetryTimer.Enabled := False;
RetryTimer.Interval := 3000;
Authenticating := True;
AuthTimer.Enabled := True;
StayAlive.Enabled := True;
End;
Procedure TFK20Elevator.ServerException(AContext: TIdContext; AException: Exception);
Begin
If AnsiContainsText(AException.Message, 'Gracefully') Then
AStatus1.SimpleText := 'Server bound to ' + LIP + ':' + IntToStr(DefPort + StrToIntDef(UnitID, 0)) //closed gracefully message
Else
Begin //show the exception
Memo1.Lines.Add('An exception happend! - ' + AException.Message);
RetryTimer.Enabled := True;
End;
Manager := False;
Authenticating := False;
End;
Procedure TFK20Elevator.ServerExecute(AContext: TIdContext);
//EncStr and DecStr simply encode/decode, respectively, a standard
// string into/from a key encrypted hex string, i.e. '00' to 'FF'
// for each character in the string
Var
S, UserName, Password: String;
I, N: Integer;
Begin
S := AContext.Connection.IOHandler.ReadLn(IndyTextEncoding_OSDefault, IndyTextEncoding_OSDefault); //get the data
If S = Heart Then //if message is the client heart beat, return to client
Begin //just a heart beat, reset timer
StayAlive.Enabled := False;
AContext.Connection.IOHandler.WriteLn(Heart, IndyTextEncoding_OSDefault, IndyTextEncoding_OSDefault);
StayAlive.Enabled := True;
Exit;
End;
S := PCommon.DecStr(S, EncDecStr, EncDecSIdx); //not heart beat, decompress
If Authenticating Then
Begin //test log in
If Length(S) > 3 Then
Begin
I := Pos('|', S);
If (I > 1) And (Length(S) > I) Then
Begin
UserName := Copy(S, 1, I - 1);
Password := Copy(S, I + 1, Length(S) - I);
If UserName = ManUser Then
Begin
If Password = ManPass Then
Begin
AuthTimer.Enabled := False;
Manager := True;
Authenticating := False;
AContext.Connection.IOHandler.WriteLn(EncStr(AContext.Binding.PeerIP +
':' + IntToStr(DefPort + StrToIntDef(UnitID, 0)) + 'M',
EncDecStr, EncDecSIdx), IndyTextEncoding_OSDefault,
IndyTextEncoding_OSDefault);
AStatus1.SimpleText := 'Connecting to> ' + AContext.Binding.PeerIP + ' as Manager';
Connected := True;
End
Else
AuthTimerTimer(Self);
End
Else If UserName = GenUser Then
Begin
If Password = GenPass Then
Begin
AuthTimer.Enabled := False;
Authenticating := False;
AContext.Connection.IOHandler.WriteLn(EncStr(AContext.Binding.PeerIP +
':' + IntToStr(DefPort + StrToIntDef(UnitID, 0)) + 'U',
EncDecStr, EncDecSIdx), IndyTextEncoding_OSDefault,
IndyTextEncoding_OSDefault);
AStatus1.SimpleText := 'Connecting to> ' + AContext.Binding.PeerIP + ' as General User';
Connected := True;
End
Else
AuthTimerTimer(Self);
End
Else
AuthTimerTimer(Self);
End
Else
AuthTimerTimer(Self);
End
Else
AuthTimerTimer(Self);
End
Else
Begin //test for commands
If Copy(S, 1, Length(AssignID)) = AssignID Then
Begin //command to assign a new unit id
NewLoc := DefLocation;
NewUnit := DefUnitNum;
I := Pos('-', S, 1);
If (I > 0) And (I < Length(S)) Then
Begin
N := Pos('-', S, I + 1);
If (N > 0) And (N < Length(S)) Then
Begin
NewLoc := Copy(S, I + 1, N - I - 1);
NewUnit := Copy(S, N + 1, Length(S) - N);
End;
End;
Label15.Caption := NewLoc;
Label16.Caption := NewUnit;
FmtStr(LIP, '%.3d', [StrToInt(NewUnit)]);
LIP := '192.168.6' + Copy(LIP, 1, 1) + '.' + Copy(LIP, 2, 2); //wifi ip
Memo1.Lines.Add('--> ' + S + '-' + LIP);
AContext.Connection.IOHandler.WriteLn(PCommon.EncStr(Rebooting, EncDecStr, EncDecSIdx),
IndyTextEncoding_OSDefault, IndyTextEncoding_OSDefault);
Memo1.Lines.Add('<-- ' + Rebooting);
TestTimer.Enabled := True;
End;
End;
End;
Procedure TFK20Elevator.ASpeedBtn2Click(Sender: TObject);
Begin //shut down the server with optional restart if not rebooting
AuthTimer.Enabled := False;
RetryTimer.Enabled := False;
StayAlive.Enabled := False;
TestTimer.Enabled := False;
DropClient;
Try
Server.Active := False;
Except
On E: Exception Do
Memo1.Lines.Add('Error disconnecting server - ' + E.Message);
End;
If Server.Active Then
Exit;
ASpeedBtn1.Enabled := True;
ASpeedBtn2.Enabled := False;
AStatus1.SimpleText := 'Server not running...';
Manager := False;
Authenticating := False;
Connected := False;
RetryTimer.Enabled := Not SysReboot;
End;
Procedure TFK20Elevator.ServerDisconnect(AContext: TIdContext);
Begin
StayAlive.Enabled := False;
RetryTimer.Enabled := False;
DropClient;
AStatus1.SimpleText := 'Client disconnected...';
Manager := False;
Authenticating := False;
Connected := False;
RetryTimer.Enabled := Not SysReboot;
End;
Procedure TFK20Elevator.DropClient; //make sure buffers are cleared
Var
I: Integer;
SC: TIdContext;
Begin
If Server.Active Then
Begin
Application.ProcessMessages;
With Server.Contexts.LockList Do
Try
Memo1.Lines.Add('Disconnecting...');
For I := Count - 1 DownTo 0 Do
Begin
SC := TIdContext(Items[I]);
If SC = Nil Then
Continue;
SC.Connection.IOHandler.WriteBufferClear;
SC.Connection.IOHandler.InputBuffer.Clear;
SC.Connection.IOHandler.Close;
If SC.Connection.Connected Then
SC.Connection.Disconnect;
Memo1.Lines.Add('Disconnecting client ' + IntToStr(I + 1) + ' of ' + IntToStr(Count));
End;
Finally
Server.Contexts.UnlockList;
Memo1.Lines.Add('Disconnected');
End;
End;
End;
Procedure TFK20Elevator.StayAliveTimer(Sender: TObject);
Begin //server reset timer if client stops sending heart beat
StayAlive.Enabled := False;
AStatus1.SimpleText := 'Client timed out!';
If ASpeedBtn2.Enabled Then
ASpeedBtn2Click(Self);
End;
Procedure TFK20Elevator.AuthTimerTimer(Sender: TObject);
Begin //login authorization timeout timer
AuthTimer.Enabled := False;
ASpeedBtn2Click(Self);
Application.ProcessMessages;
ASpeedBtn1Click(Self);
End;
또한 Pango-CRITICALs를 많이 확보하십시오. ServerDisconnect에서 DropClient를 사용 불가능으로 설정하려고 시도했지만 도움이되지 않습니다. – user7475089
메시지의 일부 : – user7475089
Pango가-CRITICAL ** : pango_layout_get_context : 주장! '레이아웃 = NULL은' Pango가-CRITICAL 실패 ** : pango_context_get_language : pango_context_get_metrics : 주장 '! 문맥 = NULL은' Pango가-CRITICAL ** 실패 주장을 pango_font_metrics_get_approximate_char_width : pango_font_metrics_get_approximate_digit_width : 주장 '! 메트릭 = NULL은'** Pango가-CRITICAL 실패 'PANGO_IS_CONTEXT (컨텍스트)'** Pango가-CRITICAL 실패 '! 메트릭 = NULL이'주장 클라이언트 프로그램이 실제로 등 – user7475089