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

PNEsmpl.bas - Beispielprogramm zur PNE

Uploader:MitgliedPMedia
Datum/Zeit:03.12.2007 21:16:49

'' PNE - PMedia's Networking Engine :: TelNet-Server example
''
'' Go to http://pmedia.max06.de for other (maybe stupid?) things of him
''

#include "PNE.bi"

Declare Sub OnConnect(ConData As pneConData)
Declare Sub OnIncoming(Message As String, ConData As pneConData)
Declare Sub OnDisconnect(ConData As pneConData)

Dim Terminal As pneServer

'' Creating the Server-Handler
'' (LINUX-IMPORTANT:: Change the port-number or run program as root!)
pneCreateServer(Terminal, 23, 10)

'' Bind the event "connect" to our connect-sub, other events, too.
pneBindEvent(Terminal, pneOnConnect, @OnConnect)
pneBindEvent(Terminal, pneOnIncoming, @OnIncoming)
pneBindEvent(Terminal, pneOnDisConnect, @OnDisconnect)

'' Will terminate Server at all issues
pneErrorLevel(All)

'' Status
Print "[ ok ]  Server started and ready for client connections"

''========================================================================
'' Main-Loop
''========================================================================
Do
    Sleep 10
Loop Until MultiKey(&h01) Or Inkey = Chr(255) + "k"

'' Kills all Client connects violently
pneDestroyServer(Terminal)

End

''========================================================================
'' onConnect
''========================================================================
Sub OnConnect(ConData As pneConData)
    '' Shows Client-IP on Screen
    print "[conn]  New Client: " + pneGetIP_s(ConData)

    '' He is enough for us to send a welcome message
    pneSendString(ConData, "Welcome to PNE Testserver")

End Sub

''========================================================================
'' onIncoming
''========================================================================
Sub OnIncoming(Message As String, ConData As pneConData)

    '' Shows incoming Data:
    print "[ in ]  By Client: " + pneGetIP_s(ConData)
    Print "        Message:   " + Message

    '' Answer
    pneSendString(ConData, "I am sorry to tell you, that this server currently no commands support :(")
End Sub

''========================================================================
'' onDisConnect
''========================================================================
Sub OnDisconnect(ConData As pneConData)

    '' Shows Client-IP on Screen
    print "[disc]  Client disconnected " + pneGetIP_s(ConData)

End Sub