IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

TServerSocket - Keep-alive


Sujet :

Langage Delphi

  1. #1
    Membre régulier

    Profil pro
    Inscrit en
    Août 2003
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 207
    Points : 91
    Points
    91
    Par défaut TServerSocket - Keep-alive
    Bonjour à tous et meilleurs voeux pour cette nouvelle année 2013.

    Existe t il un moyen facile de mettre ne place TCP keep alive sur TServerSocket ?

    Par exemple j'ai trouvé ce code pour HTTPServer :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    procedure TForm1.IdHTTPServer1Connect(AContext: TIdContext);
    begin
      AContext.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_KEEPALIVE, 1);
    end;

    Merci d'avance pour vos réponses
    Wilco

  2. #2
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 457
    Points
    28 457
    Par défaut
    tu parles du keepalive TCP ou HTTP ?

  3. #3
    Membre régulier

    Profil pro
    Inscrit en
    Août 2003
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 207
    Points : 91
    Points
    91
    Par défaut TCP Keep alive
    TCP keep alive

  4. #4
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 457
    Points
    28 457
    Par défaut
    et le code que tu donnes ne fonctionne pas ?!

  5. #5
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 612
    Points : 25 303
    Points
    25 303
    Par défaut
    Ce sujet devrait te plaire : ServerSocket Comment vérifier si un client est connecté
    J'y évoque juste le TCP Keep Alive sur un TidTCPServer
    Note que les développeurs Indy ont appelé leur méthode SetSockOpt en référence à l'API MS setsockopt

    Pour un TServerSocket utilise son Handle et l'API setsockopt \ SO_KEEPALIVE ou l'API
    WSAIoctl \ SIO_KEEPALIVE_VALS

  6. #6
    Membre régulier

    Profil pro
    Inscrit en
    Août 2003
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 207
    Points : 91
    Points
    91
    Par défaut
    Merci Shail,

    Aurais tu un petit exemple Delphi pour utiliser cette fonction ?

    Merci d'avance,
    Wilco

  7. #7
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 612
    Points : 25 303
    Points
    25 303
    Par défaut
    Tu ne fournis pas bcp d'effort !

    "setsockopt SO_KEEPALIVE tclientsocket"

    Premier lien : Embarcadero Newsgroups Archived.At > Re: How to detect connection state in TClientSocket? [Edit]

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    procedure TForm1.sckClientConnect(Sender: TObject; Socket: TCustomWinSocket);
    var
      KeepAliveEnabled: BOOL; // not Boolean!
    begin
      ListMessage('Connected to: ' + Socket.RemoteAddress);
      if ckbUseKA.Checked then
      begin
        ListMessage('Activating Keepalive');
        KeepAliveEnabled := True;
        WinSock.SetSockOpt(Socket.SocketHandle, SOL_SOCKET, SO_KEEPALIVE,
                          PChar(@KeepAliveEnabled), SizeOf(KeepAliveEnabled));
      end;
      stxLED.Color := clLime;
      btnDisconnect.Enabled := true;
      btnConnect.Enabled := false;
    end;

  8. #8
    Membre régulier

    Profil pro
    Inscrit en
    Août 2003
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2003
    Messages : 207
    Points : 91
    Points
    91
    Par défaut TCP Keep alive
    Merci beaucoup ShaiLeTroll.

  9. #9
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 612
    Points : 25 303
    Points
    25 303
    Par défaut
    N'oublie pas en bas à droite

Discussions similaires

  1. keep alive ?
    Par r1-1024 dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 24/09/2009, 12h04
  2. WCF Keep-alive inactivityTimeout
    Par matdur dans le forum Windows Communication Foundation
    Réponses: 1
    Dernier message: 27/03/2008, 18h05
  3. HTTP : Keep-Alive et Stop
    Par ChamleyMaxime dans le forum Développement
    Réponses: 2
    Dernier message: 02/07/2006, 17h45
  4. Socket keep-alive
    Par Pass dans le forum MFC
    Réponses: 17
    Dernier message: 19/07/2004, 15h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo