UDP network library [german]

Developed or developing a new product in PureBasic? Tell the world about it.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

UDP network library [german]

Post 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
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

english translation will be follow this week.stay tuned :)
SPAMINATOR NR.1
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Now this post i consider importent :D
And english Yes thank you :D

Bedst Regards
Henrik.
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

Very nice work :)
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

> UDPConnectServer

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

Nice to see such a useful library appear though.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Sebi
New User
New User
Posts: 4
Joined: Fri Apr 25, 2003 3:34 pm

Post 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:
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post 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
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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?
Image Image
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post 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.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Is it possible that this library be updated for the new linker?

:?:
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: UDP network library [german]

Post by NoahPhense »

Very nice work. The docs so far are impeccable. A lib without good docs
is just a file.. ;)

Again, very sweet..

- np
Last edited by NoahPhense on Mon Jul 12, 2004 4:10 pm, edited 2 times in total.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

huh?

NP: have you got a version of this lib that works on 3.91?
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post 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
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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?
Post Reply