server meldet disconnect nicht
Verfasst: 25.11.2004 03:02
ich habe einen minichat zu testzwecken programmiert. läuft alles wunderbar, nur eine sache will partout nicht klappen: wenn der client closenetworkconnection(ConnectionID) nutzt, zeigt der Server dies einfach nicht an.
server:
client:
jemand eine idee?
server:
Code: Alles auswählen
InitNetwork()
OpenConsole()
ConsoleColor(15,0)
PrintN("Server 1.0")
PrintN("**********")
PrintN("")
Print("Port : ")
port.l = Val(Input())
PrintN("")
PrintN("_____")
CreateNetworkServer(port)
*read_buf = AllocateMemory(1024)
Repeat
ConsoleColor(15,0)
taste$ = Inkey()
If Left(taste$,1) = Chr(9)
ConsoleColor(12,0)
Print("Text : ")
SendNetworkString(NetworkClientID(),Input())
PrintN("")
EndIf
If NetworkServerEvent() = 1
PrintN("Neuer Client!")
PrintN("_____")
EndIf
If NetworkServerEvent() = 4
PrintN("Client left!")
PrintN("_____")
EndIf
If NetworkServerEvent() = 2
ConsoleColor(10,0)
Repeat
client_id = NetworkClientID()
bytes_rec = ReceiveNetworkData(client_id, *read_buf, 1024)
Print("Incoming : " + PeekS(*read_buf,bytes_rec))
Until(bytes_rec < 1024)
PrintN("")
EndIf
Delay(10)
Until Left(taste$, 1) = Chr(27)
CloseNetworkServer()
CloseConsole()
Code: Alles auswählen
InitNetwork()
OpenConsole()
ConsoleColor(15,0)
*read_buf = AllocateMemory(1024)
PrintN("Client 1.0")
PrintN("**********")
PrintN("")
Print("IP : ")
ip.s = Input()
PrintN("")
Print("Port : ")
port.l = Val(Input())
PrintN("")
PrintN("_____")
ConnectionID = OpenNetworkConnection("127.0.0.1",port)
Repeat
ConsoleColor(15,0)
taste$ = Inkey()
If Left(taste$,1) = Chr(9)
ConsoleColor(12,0)
Print("Text : ")
SendNetworkString(ConnectionID,Input())
PrintN("")
EndIf
If NetworkClientEvent(ConnectionID) = 2
ConsoleColor(10,0)
Repeat
bytes_rec = ReceiveNetworkData(ConnectionID, *read_buf, 1024)
Print("Incoming : " + PeekS(*read_buf,bytes_rec))
Until(bytes_rec < 1024)
PrintN("")
EndIf
Delay(10)
Until Left(taste$, 1) = Chr(27)
CloseNetworkConnection(ConnectionID)
CloseConsole()