AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Aus IP und Port wieder DWord machen
Thema durchsuchen
Ansicht
Themen-Optionen

Aus IP und Port wieder DWord machen

Ein Thema von Kanne_Kaffe · begonnen am 7. Jan 2007 · letzter Beitrag vom 8. Jan 2007
 
Kanne_Kaffe

Registriert seit: 10. Okt 2005
25 Beiträge
 
#3

Re: Aus IP und Port wieder DWord machen

  Alt 7. Jan 2007, 22:14
Hallo Christian,

Nein, denke ich jedenfalls nicht.

Ich will eigendlich eine TCP verbidung beenden. Unddabei kommt es zur AV
Delphi-Quellcode:

type
  TSetTcpEntry= Function(pTcpRow: PMIB_TCPROW): DWORD; stdcall;

type
  MIB_TCPROW = packed record
    dwState,
    dwLocalAddr,
    dwLocalPort,
    dwRemoteAddr,
    dwRemotePort: DWORD;
  end;
  PMIB_TCPROW = ^MIB_TCPROW;

function CloseTCPConnection(pTcpRow: PMIB_TCPROW): Boolean;
begin
   pTcpRow.dwState := MIB_TCP_STATE_DELETE_TCB;
   if pSetTcpEntry(pTcpRow) = NO_ERROR then
    Result := True
   else
    Result := False;
end;

function TForm1.GetTCPRow: PMIB_TCPROW;
var
  I, X: Integer;
  S, sLocalIp, sRemoteIp: String;
  iLocalPort, iRemotePort: Cardinal;
begin
  if ListView1.ItemIndex = -1 then exit;
  S := ListView1.Items.Item[ListView1.ItemIndex].SubItems[1];
  X := Pos(':', S);
  sLocalIp := Copy(S, 1, X-1);
  iLocalPort := StrToInt( Copy(S, X+1, Length(S)) );

  S := ListView1.Items.Item[ListView1.ItemIndex].SubItems[2];
  X := Pos(':', S);
  sRemoteIp := Copy(S, 1, X-1);
  iRemotePort := StrToInt( Copy(S, X+1, Length(S)) );

  Result.dwLocalAddr := GetAddress(PAnsiChar(sLocalIp)); // und hier kommt die AV
  Result.dwLocalPort := GetPort(iLocalPort); // functionen wie oben geschrieben
  Result.dwRemoteAddr := GetAddress(PChar(sRemoteIp));
  Result.dwRemotePort := GetPort(iRemotePort);
end;

procedure TForm1.Schliessen1Click(Sender: TObject);
begin
  if CloseTCPConnection(GetTCPRow) then
    showmessage('Verbindung geschlossen')
    else
    showmessage('Fehler');
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:24 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz