1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Use sock_recvfrom with raklib udp socket

Discussion in 'Development' started by Kyd, Apr 20, 2018.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I want to use this function, but it's not static. So my question is how to use sock_recvfrom with udpserversocket?
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    with socket_connect it's not accepted
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    From where do you want to use this function? From a plugin?!
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    yes, from plugin
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    sorry, but why on earth would you want that?
    Also, the UDPServerSocket is on another THREAD and plugins are not really meant to interact with RakLib. What do you want to do?
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    i want to read buffers which are sent to my server by another server, but pocketmine ignore the buffer if it's not any valid datapacket
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    why do you not create a new socket for your custom communication?
     
  8. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    because it block main thread then when I try to receive something
     
  9. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    then create a thread!
     
  10. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    after I receive buffer in thread it execute only one time after and stop
    PHP:
    public function run(){
        while(
    true){
            echo 
    '1';
            if(@
    socket_recvfrom($this->clientConnection$buffer655350$address$port) !== false){
                echo 
    '2';
            }else{
                
    sleep(1);
            }

        }
    }
    so in console it's "121"
     
  11. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    probably you're not sending anything anymore and it's waiting for data.
     
    Kyd likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.