02-23-2010, 01:44 AM
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:
Now I can receive the packet. I'm still trying to extract the sender's address.
Update2: (am I talking to myself?)
Wrong, not
but
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.
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
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.