Results 1 to 8 of 8

Thread: TCP UPD Example server and client Message

  1. #1

    TCP UPD Example server and client Message

    Halo,

    How is everyone?

    Ja, well okay um i have been looking at the TCP/UPD example in Thinbasic samples.

    In the code there is a function that is used to send a data packet declared as sMessage

    Client Side

    gData.InfoData.iBroadcast.sMessage  = "Something"
    
    This is what the client sends to the server.

    I am struggling, with getting the IF statement working, what i want to do is that on the server side if a message for example "Somthing" gets received it should respond by creating a MsgBox 0, "success!"


    Server Side

     If gData.InfoData.iBroadcast.sMessaget(CBHNDL) = "Something" Then 
               MsgBox(0, "success?")
    
    I have to get it so that if the message is received that it displays the msgbox.

    Thanks for the help in advance

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

    Re: TCP UPD Example server and client Message

    Hi Laatwaai and welcome to thinBasic community forum.

    What exactly is not working?
    Do you get a runtime error message?
    Or are you haveing un-expected results?

    There are two kind of IF ... statements: single line or multiple line
    Single line it means all the IF statement must be on a single line
    Multiple lines means the IF statement must finish with a END IF
    Your example seems breaking single line rule.

    Anyway, any more info would be precious to try to understand the problem.

    Ciao
    Eros
    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

    Re: TCP UPD Example server and client Message

    Hey, Thank you very much :P

    The script it self is working, i just want to add a statement which i showed above before, but im not 100% sure if its correct syntax.

    Ah i was using one line IF statement. I fixed it up, i think but what i want to do is that, when the server receives the "smessage"
    from the client

    line 166 in the client sample -
    gData.InfoData.iBroadcast.sMessaget  = "Hey"
    
    i want to make it that if the server receives the "sMessaget" from the client that states a keyword such as "Hey"

    line 144 in the Server sample -
    WriteLog CBHNDL, "  Message is: " & gData.InfoData.iBroadcast.sMessage
    
    I want to make an if statement for the gData.InfoData.iBroadcast.sMessage if it contains the keyword "Hey' that it creates the msgbox

    Thanks, i hope that makes sense, in some way.



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

    Re: TCP UPD Example server and client Message

    Check also example in http://community.thinbasic.com/index.php?topic=494.0

    Regarding IF I think you can use something like

    DIM lPos AS LONG
    lPos = INSTR(ucase$(gData.InfoData.iBroadcast.sMessage), "HEY") '---All UCASE because INSTR is case sensitive
    IF lPos THEN
      MSGBOX 0, "HEY is present at position " & lPos
    END IF
    
    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

    Re: TCP UPD Example server and client Message

    Haha, excellent i see how you used the function, i will learn well from this example.

    Thanks for your time Eros

    I will contiune working on it and learning, if i make any good improvements will post them

    Cheers

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

    Re: TCP UPD Example server and client Message

    Attention to firewalls also for local communications
    Under Windows 7 you have to authorize your scripts to access network and/or open some ports both as client or as server.
    Under Windows XP if firewall is on you have to authorize your application (thinBasic.exe) to access some ports.

    For testing it is better to temporarily switch off any firewall
    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

    Re: TCP UPD Example server and client Message

    Hi Laatwai and welcome on the board.

    I attached Eros Chat example to my post, so you can see in a different example how messages are sent and received.

    Cheers
    Michael
    Attached Files Attached Files

  8. #8

    Re: TCP UPD Example server and client Message

    Hey Eros thanks yeah im doing it on my local host 127.0.0.1 I wanted to do a test over my network using the 192 IP, range which worked fine thanks for all the help.

    Thanks Michael looks interesting ill look at it tonight

    Thanks for all the help and warm welcomes ^^

    Take care

    Cheers

Members who have read this thread: 2

Posting Permissions

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