Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Receive UDP packets with RMXP
#2
Time to bump this.
I managed to receive packets by using recv and not recvfrom, but I can't read the sender's address with recv, and I need that.
select is actually working correctly. recvfrom is to blame.

Update: i found out that recvfrom was returning -1 but the SocketError class was failing to raise an exception, I guess beacuse it didn't recognize it. So, by checking the error number myself, i found out it was a 10014 error, which means some of the buffer lenghts I was passing weren't correct. I turns out the correct call to recvfrom must be:
Code:
#--------------------------------------------------------------------------
  # ? Returns received data.
  #--------------------------------------------------------------------------  
  def recvfrom(len, flags = 0)
    buf = "\0" * len
    buf2 = "\0" * 2
    buf3 = "\0" * 1
    SocketError.check if (result = Winsock.recvfrom(@fd, buf, buf.size, flags, buf2, buf3)) == -1
    return buf, buf2, buf3
  end

Now I can receive the packet. I'm still trying to extract the sender's address.

Update2: (am I talking to myself?)
Wrong, not
Code:
buf2 = "\0" * 2
    buf3 = "\0" * 1
but
Code:
buf2 = "\0" * 20
    buf3 = "\0" * 1

however, it still gives error 10014 sometimes.

Update3: And I managed to get the sender's address too. Be sure to play my online game when it will come out. :) This solo thread can be closed.
Reply }


Messages In This Thread
Receive UDP packets with RMXP - by Charlie Fleed - 02-18-2010, 10:38 PM
[Resolved] Receive UDP packets with RMXP - by Charlie Fleed - 02-23-2010, 01:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   [RMXP] Showing skill gained by leveling up on battle result FrQise 12 10,462 05-07-2021, 02:05 PM
Last Post: FrQise
   RMXP SKill animations too bright (overlaying the battle screen) Starmage 4 9,246 06-13-2016, 03:41 AM
Last Post: Starmage
   [RMXP]Game Over and Atoa Battle Status mishaps firestalker 8 9,782 08-07-2014, 01:59 AM
Last Post: firestalker
Star Multilanguage script petition for RMXP Iqus 11 17,562 01-07-2013, 10:50 AM
Last Post: Narzew
   [RMXP] Actor Cloning dagarath 2 8,668 03-08-2011, 07:18 AM
Last Post: dagarath
   Replace the AUDIO class for RMXP! DerVVulfman 8 13,990 10-15-2010, 06:29 PM
Last Post: yamina-chan



Users browsing this thread: