Autor Beitrag
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Mi 30.07.08 17:47 
ich hab für ein netzwerkfähiges spiel einen chat programmiert. nun hab ich versucht, im ondisconnect-ereignis des serversockets ebendiesen zu schliessen. dabei kommt es zu einer fehlermeldung (10038) die sich weder durch irgendein onerror-ereignis abfangen lässt noch durch try-except. mit einem timer, der den serversocket ne halbe sekunde später schließt, gibts keine fehlermeldung. da ich diese methode nich wirklich "gut" finde, wollt ich fragen ob es noch eine andere möglichkeit gibt, und vor allem, warum es zu dem von mir beschriebenen fehler kommt.

MfG nils
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Mi 30.07.08 18:42 
ich glaube, es war so, dass man komponenten nicht in ihren eigenen Methoden zerstören kann. Deshalb funkltioniert auch das mit dem Timer.
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Mi 30.07.08 19:25 
aber serversocket.close zerstört die komponente doch nich?
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mi 30.07.08 19:38 
www.indyproject.org/...e=EIdNotASocket.html

Zitat:
EIdNotASocket is an EIdSocketError descendant that represents the exception raised when a socket operation is performed using an invalid socket handle.


Und bevor du jetzt sagst "Ich nutz doch gar kein Indy": Der Fehler ist ja der selbe. Im OnDisconnect wird noch irgendwas mit dem Socket gemacht. Wenn du ihn aber schließt, kann nix mehr gemacht werden -> "Invalid Socket"

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Mi 30.07.08 19:46 
warum invalid socket handle?

die gleiche vorgehensweise funktioniert beim clientsocket übrigens ohne probleme...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 30.07.08 23:19 
Moin!

user profile iconhuuuuuh hat folgendes geschrieben:
warum invalid socket handle?
Weil beim OnDisconnect der Socket erst geschlossen werden soll, aber noch nicht ist.

user profile iconhuuuuuh hat folgendes geschrieben:
die gleiche vorgehensweise funktioniert beim clientsocket übrigens ohne probleme...
Ein TClientSocket ist ja auch kein TServerSocket... :|

Lösung: schick dir selbst eine Fensternachricht, in deren Handler du den TServerSocket schließt.

btw: wenn du ständig den ServerSocket schließt, dann stimmt da was mit dem Konzept deiner Anwendung nicht.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Mi 30.07.08 23:39 
der serversocket wird nur dann geschlossen wenn die verbindung beendet wird, sprich am ende eines netzwerk-spiels. bei einem chat mag es vielleicht seltsam klingen den server bei jedem ondisconnect zu schliessen, aber ich finde, nach einem netzwerk-spiel macht es durchaus sinn...