Page 1 of 1

UDP network library [german]

Posted: Wed Jun 04, 2003 2:58 pm
by gnozal
News from the german forum :

PureFan has released an UDP network library, downloadable at http://www.adventuretipps.de/purebasic/udpnetwork/ (in german)

GERMAN FORUM :
Die erste Version der UDPNetwork - Library ist fertig!!!

Im Gegenteil zu TCP-IP hat diese Übertragungsart keine Empfang-Bestätungs-Protokolle. Deshalb ist sie viel schneller und damit auch für z.B. Spiele geeignet.

Im Moment unterstützt die Library folgende Befehle


Code:
- EasyUDPSend
- UDPCloseConnection
- UDPCloseServer
- UDPConnectServer
- UDPCreateServer
- UDPDataAvailable
- UDPEndCaptureEvents
- UDPGetLocalIP
- UDPGetUserIP
- UDPGetUserPort
- UDPHostByAlias
- UDPInitNetwork
- UDPIsAvailable
- UDPLoadUserID
- UDPReceive
- UDPSaveUserID
- UDPSend
- UDPSendToUser
- UDPStartCaptureEvents
- UDPWaitUntilReceive


Diese Library wurde in handoptimiertem Assembler programmiert!
Sie wurde bereits von mehreren Personen im Chat getestet und funktionierte überall einwandfrei!

Die Hilfe dazu und die Library selbst findet ihr hier::

http://www.adventuretipps.de/purebasic/udpnetwork/

Ich würde mich sehr über Feedbacks freuen

Posted: Wed Jun 04, 2003 3:19 pm
by Rings
english translation will be follow this week.stay tuned :)

Posted: Wed Jun 04, 2003 5:34 pm
by Henrik
Now this post i consider importent :D
And english Yes thank you :D

Bedst Regards
Henrik.

Posted: Wed Jun 04, 2003 7:21 pm
by Berikco
Very nice work :)

Posted: Wed Jun 04, 2003 9:45 pm
by tinman
> UDPConnectServer

I thought UDP didn't have such things as connections?

Nice to see such a useful library appear though.

Posted: Thu Jun 05, 2003 5:18 pm
by Sebi
Hello all,
> UDPConnectServer
I thought UDP didn't have such things as connections?
Nice to see such a useful library appear though.
You are right. But this command receives the IP of the server and opens a socket. I don't think there is another way to do that...

Now the english help is available, too!! :D

http://www.adventuretipps.de/purebasic/udpnetwork_eng/

Examples are coming soon.....

Thanks to Rings for the translation 8)

PureFan or Sebi :wink:

Posted: Fri Aug 29, 2003 4:53 pm
by coma
Thanks for this UDP lib :)

But I'm looking for examples using this library.
I have try this, but it don't work :

Code: Select all

;FOR THE SERVER

*buffer = AllocateMemory(0, 1000, 0)
Port = 6832
test.UDPConnect

UDPInitNetwork() 
UDPCreateServer(port, test.UDPConnect)
UDPStartCaptureEvents (test) 

Repeat
    ExamineKeyboard()
    If  UDPReceive (test, *buffer, 4) 
       x=PeekW(*buffer)
       y=PeekW(*buffer+2)
    EndIf
Until KeyboardPushed(#PB_Key_Escape) 

UDPEndCaptureEvents (test) 
UDPCloseServer (test) 
End
and this for the client :

Code: Select all

;FOT THE CLIENT
 
*buffer = AllocateMemory(0, 1000, 0)
Port = 6832
test.UDPconnect

UDPInitNetwork() 
UDPConnectServer(port, "217.128.179.97", test) 
        
Repeat
    ExamineKeyboard()
    PokeW(*buffer, x)
    PokeW(*buffer+2, y)
    UDPSend(test, *buffer, 4)

    FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape) 

UDPCloseConnection(test)
End

Posted: Fri Aug 29, 2003 6:09 pm
by Paul
Your code works fine if you just add a few extra lines that are needed to actually compile it ;)


Turn your debugger on and run the server...

Code: Select all

;FOR THE SERVER 

*buffer = AllocateMemory(0, 1000, 0) 
Port = 6832 
test.UDPConnect 

UDPInitNetwork() 
UDPCreateServer(port, test.UDPConnect) 
UDPStartCaptureEvents (test) 

If OpenWindow(0,0,0,300,200,#PB_Window_SystemMenu,"Server")
  Repeat
    Delay(1)    
    If  UDPReceive (test, *buffer, 4) 
       x=PeekW(*buffer) 
       y=PeekW(*buffer+2)
       Debug Str(x)+".."+Str(y) 
    EndIf 
  Until WindowEvent()=#PB_Event_CloseWindow 
EndIf

UDPEndCaptureEvents (test) 
UDPCloseServer (test) 
End


Now run the client (on the same computer) and press A or B. The debugger window will show that the info is getting through.

Code: Select all

;FOR THE CLIENT 
InitKeyboard()
InitSprite()

*buffer = AllocateMemory(0, 1000, 0) 
Port = 6832 
test.UDPconnect 

UDPInitNetwork() 
UDPConnectServer(port, "127.0.0.1", test) 


If OpenWindow(0,0,0,200,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"")
  If OpenWindowedScreen(WindowID(),0,0,640,480,0,0,0)=0:End:EndIf
EndIf

        
Repeat 
    ExamineKeyboard() 
    If KeyboardReleased(#PB_Key_A)
      PokeW(*buffer, 1) 
      PokeW(*buffer+2, 2) 
      UDPSend(test, *buffer, 4)
    EndIf
    If KeyboardReleased(#PB_Key_B)
      PokeW(*buffer, 3) 
      PokeW(*buffer+2, 4) 
      UDPSend(test, *buffer, 4)
    EndIf

    FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape) 

UDPCloseConnection(test) 
End
It works fine here so if you are getting nothing, maybe you have a firewall running that is blocking your ports?

Posted: Sat Aug 30, 2003 5:49 pm
by coma
ok, now it works, but when I receive data, my program slow down, on the server.

on the server, my main loop look like this :

Code: Select all

Repeat
    ExamineKeyboard()
    ExamineMouse()

    StartDrawing (ScreenOutput())
        // here, some drawing stuff (I draw a plot at player2x,player2y coordinates)
    StopDrawing()


    If  UDPReceive (test, *buffer, 4) 
        player2x=PeekW(*buffer)
        player2y=PeekW(*buffer+2)
    EndIf

       FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape)
with the client, I send data every 10 frames :

Code: Select all

Repeat
    ExamineKeyboard()
    ExamineMouse()

    StartDrawing (ScreenOutput())
        //some drawing here
    StopDrawing()

    If sendfreq=0
        PokeW(*buffer, playerx)
        PokeW(*buffer+2, playery)
        UDPSend(test, *buffer, 4)
    EndIf
    sendfreq+1 :  If sendfreq>10 : sendfreq=0 : EndIf

    // here I update player positions

    FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape) 
There's any slow down on client. Only on the server when it receive a message from the client.

Posted: Sun Jul 11, 2004 10:24 pm
by DoubleDutch
Is it possible that this library be updated for the new linker?

:?:

Re: UDP network library [german]

Posted: Mon Jul 12, 2004 12:45 am
by NoahPhense
Very nice work. The docs so far are impeccable. A lib without good docs
is just a file.. ;)

Again, very sweet..

- np

Posted: Mon Jul 12, 2004 7:59 am
by DoubleDutch
huh?

NP: have you got a version of this lib that works on 3.91?

..

Posted: Mon Jul 12, 2004 4:13 pm
by NoahPhense
DoubleDutch wrote:huh?

NP: have you got a version of this lib that works on 3.91?
No, I have not yet tried this library. I was just comending them on such
a nice lib to have created. It's the type of library that helps bring PB up
a notch. As well, it shows that people still have big plans for PB.

I will follow this lib as it developes.

- np

Posted: Mon Jul 12, 2004 5:04 pm
by DoubleDutch
it is a really good lib, it should be part of the standard package (if someone does a linux version of the commands).

its just a pity it doesn't work with the latest version! :(

maybe they could make the source available for updating?