|Anonymous | Login | Signup for a new account||2017-12-12 06:37 GMT|
|My View | View Issues | Roadmap | My Account|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0028479||Runner||Functions||Public||2017-12-05 16:00||2017-12-06 10:58|
|Assigned To||Claire Hall|
|Priority||Low||Severity||C - General||Reproducibility||100%|
|Summary||0028479: Functions: network_send_packet doesn't work properly on Windows 7|
|Description||As I was programming multiplayer for my game (a block game similar to Terraria), I encountered a problem where only a few of my chunks of terrain data were sent from the server to the client. The chunks that were sent successfully all had network_send_packet return the correct amount of bytes sent, but for the chunks that didn't reach the client, the server's network_send_packet calls returned "-1". I have been looking for a solution for a very long time now, but can't find one, so I'm pretty sure it's a GM bug. I have created a new, smaller project for you (the gmz in the sample URL) which is a simple version of what happens in my game.|
|Steps To Reproduce||Create an executable with the project (a windows VM executable, I haven't tested windows YYC). Run the executable and click "Yes" for it to start as a server. Then run another instance of the executable and click "No" for it to start as a client. A connection should be established without any issues and the server should show "Connections: 1" in its window while the client's window should show "Connected". Make sure the client's window is selected, then click Space on your keyboard. This should send 16 packets to the server (in my game, these packets symbolize requests for getting 16 different chunks of data from the server's world terrain). The server's executable will receive these requests and send 1 response packet per request, which should in total give a number of 16 response packets sent back to the client. The problem is that this is not the case. In my tests, the client manages to send all requests without issue (you can see this in the text in the client's window), but it only receives a few of the response packets (you can see this as well in the text in the client's window). If it worked as expected it should show 16/16. But it shows values around 7/16. The reason for the client not receiving all the response packets is that the server's network_send_packet calls sometimes fail (in these cases the server's network_send_packet call returns -1).|
|Additional Information||If you go to the asynchronous event in object0, there's a variable called buffer_size. This is set to 4000 meaning the response packets (without header) has a size of 4000 bytes (about the same as the terrain chunks in my game). Reducing the number to 1000 seems to let the client receive more response packets, but there are still a few not being received (around 13/16 received). Only with a very small packet size, all the response packets are received. As the system uses TCP, I would expect all packets to be received.|
network_send_packet is a very important function in GameMaker, and since sending world data the way I do is very common this bug causes a huge risk to many developers.
|2.x Runtime Version|
|2.x Runtime Version Verified In|
|Attached Files||Bug report - network_send_packet not working.gmz [^] (9,485 bytes) 2017-12-05 16:00|
Peter Hall (Developer)
I think the key bit is 'the server's network_send_packet calls returned "-1"'
network_send_packet can return -1 if:
- the buffer you're trying to send from is bad
- the socket id you're passing in is bad
- windows socket layer returns SOCKET_ERROR (which is -1)
I suspect the latter. Really we should then call WSAGetLastError to find out what the real error is and report that (I suspect something like WSAEWOULDBLOCK or WSAEINPROGRESS). To make the network code a bit easier to use, maybe we should then retry sending for these errors?
|Copyright © 2000 - 2017 MantisBT Team|