Files
LoopzRemix/Network.pbi
2025-07-17 20:36:20 +02:00

56 lines
1.1 KiB
Plaintext

EnableExplicit
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
Procedure NetworkLoop()
Protected Port.l = 80
Protected *Buffer = AllocateMemory(1000)
Protected Cnx.i = OpenNetworkConnection("82.64.24.137", Port)
Protected NEvent.i
Protected Quit=#False
If Cnx
Debug "connextion"
SendNetworkString(Cnx, "An hello from a client !!! :-)", #PB_UTF8)
Debug "envoye"
Repeat
NEvent=NetworkClientEvent(Cnx)
If NEvent
Select NEvent
Case #PB_NetworkEvent_None
Debug "A new client has connected !"
Case #PB_NetworkEvent_Data
Debug " has send a packet !"
ReceiveNetworkData(Cnx, *Buffer, 1000)
If PeekS(*Buffer, -1, #PB_UTF8)="ok"
Quit=#True
EndIf
Case #PB_NetworkEvent_Disconnect
Debug "has closed the connection..."
Quit = #True
EndSelect
EndIf
Delay(1)
Until Quit=1
EndIf
Debug "on a quitter"
End
EndProcedure
NetworkLoop()
; IDE Options = PureBasic 6.00 Beta 6 (Windows - x64)
; CursorPosition = 34
; FirstLine = 1
; Folding = -
; EnableXP