Probleme avec le reseau
Publié : jeu. 15/juil./2004 5:55

[/code];BY GARZUL
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Image_2
#String_0
#Button_0
#Button_1
#Text_1
EndEnumeration
;- Image Plugins
UseJPEGImageDecoder()
;- Image Globals
Global Image0
;- Catch Images
Image0 = CatchImage(0, ?Image0)
;- Images
DataSection
Image0:
IncludeBinary "C:\Documents and Settings\verneuil julien\Mes documents\Mes images\serveur.JPG"
EndDataSection
Procedure Open_Window_0()
If OpenWindow(#Window_0, 340, 140, 604, 300, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "Serveur du chaos")
If CreateGadgetList(WindowID())
ImageGadget(#Image_2, 0, 0, 150, 310, Image0)
StringGadget(#String_0, 150, 0, 450, 190, "Le serveur et actuellement hors service demarrer le si vous voulez qu'il s'allume!", #PB_String_ReadOnly)
GadgetToolTip(#String_0, "Description du serveur")
AdvancedGadgetEvents(1)
ButtonGadget(#Button_0, 150, 260, 130, 30, "Demarrer", #PB_Button_Default| #PB_EventType_RightClick)
ButtonGadget(#Button_1, 470, 260, 130, 30, "Arreter", #PB_Button_Default)
TextGadget(#Text_1, 230, 240, 280, 20, "Note toujour veiller au fonctionnemen du serveur.", #PB_Text_Center)
EndIf
EndIf
EndProcedure
Procedure initnet()
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
Port = 6832
Buffer = AllocateMemory(1000)
If CreateNetworkServer(Port)
SetGadgetText(#String_0, "Le serveur et demarrer sur le port " +Str(Port))
Repeat
SEvent.l = NetworkServerEvent()
If SEvent
ClientID = NetworkClientID()
Select SEvent
Case 1
SetGadgetText(#String_0, "Un nouveau client c'est conecter !")
EndSelect
EndIf
Until Quit = 1
MessageRequester("PureBasic - Server", "Clicqu pour quitter le serveur.", 0)
CloseNetworkServer()
Else
MessageRequester("Error", "Can't create the server (port in use ?).", 0)
EndIf
EndProcedure
Open_Window_0()
initnet()
Repeat
event=WaitWindowEvent()
EventType()
If event= #PB_EventCloseWindow
Quit = 1
EndIf
Until Quit = 1