leider scheitert der Versuch, einen UDP Server mit Port 1009 zu öffnen.
Nehme ich z.B. Port 7009 funktioniert es wunderbar.
Nach etlicher Suche im WWW wurde ich aber leider nicht fündig wie bei einem MAC die Ports verwaltet werden bzw. wo der "Haken" liegt dass ich den Port 1009 nicht öffnen kann.
Nehme ich den Code und starte das ganze auf einen "Windows" Maschine ist es kein Problem!!
Anbei der Code:
Code: Alles auswählen
Enumeration
#GADGET_Canvas
#GADGET_Color
#GADGET_Auf
#GADGET_Ab
#GADGET_Links
#GADGET_Rechts
#GADGET_Gross
#GADGET_Klein
#GADGET_ENDE
#GADGET_Ausgabe
EndEnumeration
Global CurrentColor, CurrentMode, StartX, StartY
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
Port = 1009
*Buffer = AllocateMemory(1000)
Global WPx,WPy,WPw,WPh,FS
FS=40
WPx=0
WPy=0
LoadFont (0, "Arial", FS) ; Load Arial Font, Size 40
If OpenWindow(0, WPx,WPy, 850, 300, "Laps To Go Server", #PB_Window_BorderLess )
SetWindowColor(0, %000000)
ButtonGadget(#GADGET_Gross, 730, 30, 100, 25, "Groß" )
ButtonGadget(#GADGET_Klein, 730, 60, 100, 25, "klein")
ButtonGadget(#GADGET_Auf, 730, 100, 100, 25, "Auf")
ButtonGadget(#GADGET_Ab, 730, 130, 100, 25, "Ab")
ButtonGadget(#GADGET_Links, 730, 160, 100, 25, "Links")
ButtonGadget(#GADGET_Rechts, 730, 190, 100, 25, "Rechts")
ButtonGadget(#GADGET_ENDE, 730, 250, 100, 25, "QUIT")
TextGadget(#GADGET_Ausgabe,10,20,570,330,"",#PB_Text_Right)
SetGadgetColor(#GADGET_Ausgabe, #PB_Gadget_BackColor , $000000)
SetGadgetColor(#GADGET_Ausgabe, #PB_Gadget_FrontColor , $00FFFF)
SetGadgetFont(#GADGET_Ausgabe, FontID(0))
If CreateNetworkServer(0, Port, #PB_Network_UDP)
MessageRequester("Laps To Go Server", "Server created (Port "+Str(Port)+").", 0)
SetGadgetText(#GADGET_Ausgabe,"00:00:00")
Repeat
SEvent = NetworkServerEvent()
Event = WindowEvent()
If SEvent
ClientID = EventClient()
; ClientIP = GetClientIP(ClientID)
; ClientIP$ = IPString(ClientIP)
; Debug ClientID
; Debug ClientIP
; Debug ClientIP$
Select SEvent
; Case #PB_NetworkEvent_Connect
; MessageRequester("PureBasic - Server", "A new client has connected !", 0)
;
Case #PB_NetworkEvent_Data
ReceiveNetworkData(ClientID, *Buffer, 100)
inDaten$ = PeekS(*Buffer)
inDaten$ = Mid(indaten$,5)
indaten$ = Left(indaten$,Len(inDaten$) -3)
If Left(inDaten$,2)="--"
indaten$="FINISH"
EndIf
If Right(indaten$, 2) = "LP"
indaten$ = Trim(indaten$)
L$ = Left(indaten$, Len(indaten$)-3)
If Val(L$) > 1
indaten$ = L$ + " LAPS"
ElseIf Val(L$) = 1
indaten$ = "1 LAP"
Else
indaten$ = "FINISH"
EndIf
EndIf
SetGadgetText(#GADGET_Ausgabe,inDaten$)
FillMemory(*Buffer, 100)
Case #PB_NetworkEvent_Disconnect
Quit = 1
EndSelect
EndIf
If Event = #PB_Event_Gadget
Select EventGadget()
Case #GADGET_Auf
wpy=wpy-1
ResizeWindow(0, #PB_Ignore, wpy, #PB_Ignore, #PB_Ignore)
SetGadgetText(#GADGET_Auf,"Auf > "+Str(wpy))
SetGadgetText(#GADGET_Ab,"Ab > "+Str(wpy))
Case #GADGET_Ab
wpy=wpy+1
ResizeWindow(0, #PB_Ignore, wpy, #PB_Ignore, #PB_Ignore)
SetGadgetText(#GADGET_Auf,"Auf > "+Str(wpy))
SetGadgetText(#GADGET_Ab,"Ab > "+Str(wpy))
Case #GADGET_Links
wpx=wpx-1
ResizeWindow(0, wpx, #PB_Ignore, #PB_Ignore, #PB_Ignore)
SetGadgetText(#GADGET_Links,"links > "+Str(wpx))
SetGadgetText(#GADGET_Rechts,"rechts > "+Str(wpx))
Case #GADGET_Rechts
wpx=wpx+1
ResizeWindow(0, wpx, #PB_Ignore, #PB_Ignore, #PB_Ignore)
SetGadgetText(#GADGET_Links,"links > "+Str(wpx))
SetGadgetText(#GADGET_Rechts,"rechts > "+Str(wpx))
Case #GADGET_Klein
fs=fs-1
LoadFont (0, "Arial", FS)
SetGadgetFont(#GADGET_Ausgabe, FontID(0))
SetGadgetText(#GADGET_Klein,"klein > "+Str(fs))
SetGadgetText(#GADGET_Gross,"groß > "+Str(fs))
Case #GADGET_Gross
fs=fs+1
LoadFont (0, "Arial", FS)
SetGadgetFont(#GADGET_Ausgabe, FontID(0))
SetGadgetText(#GADGET_Klein,"klein > "+Str(fs))
SetGadgetText(#GADGET_Gross,"groß > "+Str(fs))
Case #GADGET_ENDE
Quit = 1
EndSelect
EndIf
Until Quit = 1 Or Event = #PB_Event_CloseWindow
MessageRequester("Laps To Go Server", "Click to quit the server.", 0)
CloseNetworkServer(0)
Else
MessageRequester("Error", "Can't create the server (port in use ?).", 0)
EndIf
EndIf
End