Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

Server.bas

Uploader:MitgliedThePuppetMaster
Datum/Zeit:06.12.2007 12:35:40

#include "TSNE.bi"

Dim G_Server as TSNE_Socket
Dim Shared G_ClientD() as TSNE_Socket
Dim Shared G_ClientC as Long

Dim BV as Long
Declare Sub TSNE_Disconnected (ByRef V_Socket as TSNE_Socket)
Declare Sub TSNE_Connected (ByRef V_Socket as TSNE_Socket)
Declare Sub TSNE_NewConnection (ByRef V_Socket as TSNE_Socket, ByRef V_RequestID as Socket)
Declare Sub TSNE_NewData (ByRef V_Socket as TSNE_Socket, ByRef V_Data as String)
Declare Sub TSNE_SendSuccess (ByRef V_Socket as TSNE_Socket, ByRef V_Bytes as Long)


Print "[INIT] Setup..."
TSNE_Event_Set(@TSNE_Disconnected, @TSNE_Connected, @TSNE_NewConnection, @TSNE_NewData, @TSNE_SendSuccess)

Print "[INIT] Client..."
BV = TSNE_Create_Server(G_Server, 1234, 10 , 0)
If BV = 0 Then
    Print "[OK]"
Else: Print "[FEHLER] " & TSNE_GetGURUCode(BV)
End if
Print "[WAIT] ..."
TSNE_WaitClose(G_Server)
Print "[WAIT] OK"
Print "[END]"
end


Sub TSNE_Disconnected (ByRef V_Socket as TSNE_Socket)
Print "[DIS]"
End Sub



Sub TSNE_Connected (ByRef V_Socket as TSNE_Socket)
Print "[CON]"
Dim CRLF as String
CRLF = Chr(13) & Chr(10)
TSNE_Data_Send(V_Socket, "HTTP/1.1 200 OK" & CRLF & "connection: close" & CRLF & CRLF & "TSNE-Test-Server: OK")
Dim X as Long
For X = 1 to G_ClientC
    If G_ClientD(X).T_InUse = 1 Then
        If G_ClientD(X).V_Socket = V_Socket.V_Socket Then
            TSNE_Disconnect(V_Socket)
            G_ClientD(X).T_InUse = 0
            Exit For
        End If
    End If
Next
End Sub



Sub TSNE_NewConnection (ByRef V_Socket as TSNE_Socket, ByRef V_RequestID as Socket)
Print "[NCO] >" & V_RequestID & "<"
Dim X as Long
For X = 1 to G_ClientC
    If G_ClientD(X).T_InUse = 0 Then
        TSNE_Create_Accept(V_RequestID, G_ClientD(X))
        G_ClientD(X).T_InUse = 1
        Print "[NCO] OK:" & G_ClientC
        Exit Sub
    End If
Next
G_ClientC += 1
Redim Preserve G_ClientD(G_ClientC) as TSNE_Socket
TSNE_Create_Accept(V_RequestID, G_ClientD(G_ClientC))
G_ClientD(G_ClientC).T_InUse = 1
Print "[NCO] NK:" & G_ClientC
End Sub



Sub TSNE_NewData (ByRef V_Socket as TSNE_Socket, ByRef V_Data as String)
Print "[NDA]: >" & V_Data & "<"
End Sub



Sub TSNE_SendSuccess (ByRef V_Socket as TSNE_Socket, ByRef V_Bytes as Long)
Print "[SES]"
End Sub