Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: UDP Client only for receiving data

  1. #1

    UDP Client only for receiving data

    Hello everybody - Iīm new to thinBasic (but not to Basic). Iīm searching for a simple UDP Client (only for receiving data!!) - Iīve tried the examples but they donīt work for me! Iīm trying to connect to my Raspberry Pi which is working well as a UDP-Server (I tried it with the hercules terminal!) Could somebody give me a hint how this could be done?
    Thanks in advance!

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Ciao,

    have you tried sample scripts in \thinBasic\SampleScripts\TcpUdp\
    There are 2 scripts and 1 include file:
    UDP_Notify_Server.tbasic
    UDP_Notify_Client.tbasic
    UDP_Notify_Common.INC

    The idea of this example is to use UDP to communicate from one (or more) client to a UDP server and once connected the client can control the position of the UDP server window

    Start UDP_Notify_Server script and click on "I'm a server"
    then run one client script UDP_Notify_Client and click on "Find server"
    You should see them connecting and then if you move client window it will move server window
    More than one client can be executed up to 10
    Example works searching for server on localhost but can be changed to search for specific IP address

    If not working:
    one problem can be related to Firewalls: port used to communicate must be open for UDP protocol
    Also under many Windows versions an application trying to open UDP or TCP ports as a client or as a server must be authorized as application.
    Attached Images Attached Images
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Dear Eros,

    as said before I tried all examples in TCPUDP-Directory!!

    I found this code in your forum but itīs not working!

    Uses "INet" '---Load INet module
    Uses "RAS" '---Load RAS module
    Uses "FILE" '---Load FILE module
    Uses "TCPUDP" '---Load TCPUDP module
    Uses "OS" '---Load OS module
    Uses "CONSOLE" '---Load CONSOLE module

    DIM pbxip AS LONG
    DIM pbxname AS STRING
    DIM udpconnid AS LONG
    pbxip = HOSTNAME_TOIP("pbv01")
    pbxname = HOSTIP_TONAME(pbxip)
    Msg = "pbxip=" + pbxip + $CRLF
    Msg += "pbxname=" + pbxname + $CRLF
    MSGBOX(1,Msg)

    udpconnid = UDP_Open(9009,UDP_FreeFile)

    Do
    INCR Count
    sBuffer = UDP_Recv(udpconnid)
    Msg = sBuffer
    IF (Len(Msg) < 3) THEN
    Msg = "hello"
    END IF
    MSGBOX(1,Msg)
    Console_WriteLine Msg
    Loop While ((Len(sBuffer) > 0) AND (ERR = 0))

    UDP_Close(udpconnid)

    Errormessage - Unknown Keyword or variable not defined


    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Activity.PNG

    This is a snapshot of an UDP-Client that I wrote in FreeBasic - thatīs what I want but as a graphical interface!!! It just connects to the server at 192.168.1.100 on Port 48000 and receives the data showing it in a DOS-Box! I changed to thinBasic because itīs just better - I should have done so from the beginning! For now it would be good to have a program running in a DOS-Box - the graphics can be done later! But because Iīm new to thinBasic itīs hard for me to find the right way!!

    Ciao
    Peter
    Last edited by phb; 29-02-2024 at 14:38.

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I will work in the week-end on a simple script to test
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    Quote Originally Posted by ErosOlmi View Post
    I will work in the week-end on a simple script to test
    Gracie mille Eros!!!

    Cioa
    Peter

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hope this can help.

    Attached an UDP_Server script and UDP_Client. I've added both sources and bundled exe
    Tried to keep as simple as possible to concentrate only on send/receive

    UDP_Server
    on start it will open UDP port 40000 on localhost 127.0.0.1 an wait for receiving some data
    It will set a timeout of 10 seconds but will loop for next receive
    Leave the server running waiting some data

    UDP_Client
    on start will send some data to localhost 127.0.0.1 port 40000
    After sending will exit
    You can run client many times to send some new data

    Attention
    windows firewall may interfere and scripts must be allowed to send/receive data
    UDP Client is the one sending data
    UPD Server is the one receiving data


    PS:
    thinBasic help UDP_OpenServer is wrong because it reported UDP_Open instead of UDP_OpenServer
    I will fix next release.
    Attached Files Attached Files
    Last edited by ErosOlmi; 02-03-2024 at 23:41.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Works fine!

    Thank you so much Eros - thatīs a very fine example! I always thought I needed a client!! Now I know better!
    The next step is to make the program "Windowish". I already made a GUI with your Visual Designer!

    Ciao
    Peter
    Last edited by phb; 03-03-2024 at 12:47.

  8. #8

    Canīt make exe

    Thereīs no way for me to bundle a program although they work fine in the thinBasic environment. I always get the same errormessage: " Errorcode: 12000 - Obfuscated script not valid. Decript Error code:3
    Iīm using Windows 10 Professional!

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I think this is my mistake in thinBasic 1.12.0

    Please download attached thinCore.dll and copy it into \thinBasic\ path substituting the one you have
    It is thinCore 1.12.1 I'm working on and I will publish this week

    Let me know if it works
    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #10

    Works!!!!

    Thank you again Eros,

    I want to say that thinBasic is a superb Program - Itīs blistering fast and modern and your support is the best I ever had!!!!

    ciao
    Peter

Page 1 of 2 12 LastLast

Similar Threads

  1. Not receiving expected result from Comm_RECV
    By Ray in forum COMM (Serial communication)
    Replies: 10
    Last Post: 09-10-2020, 22:25
  2. Code snippet: Click to window at client coordinates
    By Petr Schreiber in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 1
    Last Post: 19-01-2015, 14:21
  3. TCP UPD Example server and client Message
    By Laatwaai in forum Tcp/Udp module
    Replies: 7
    Last Post: 21-08-2010, 13:57
  4. Data trigger and data events
    By ErosOlmi in forum TBEM module - thinBasic Event Manager module
    Replies: 9
    Last Post: 10-10-2008, 22:54

Members who have read this thread: 6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •