Skip to content
gnysek edited this page Aug 7, 2023 · 4 revisions

Welcome to the gm_boomers_networking wiki!

Differences between 39dll

  • no 39dll.dll file.
  • creating/closing sockets and network connections is done in a native GameMaker way, so no tcpconnect(), tcplisten(), tcpaccept()
  • while (receivemessage(socket)) {} is no more; instead, use GM Async - Networking in normal way, and to get async_load[? "buffer"] into global.buffer which is default buffer here (created on game start), use seize_buffer(async_load[? "buffer"]);
  • no resetbuffer_target(), setbuffer(), freebuffer(), peekmessage(), setformat(), lastip(), setsync(), closesocket(), socklasterror(), myhost(), compareip(), sockexit(), sockstart(), hostip(), setsockopt(), getsockopt(), lastport(), getsockid(), tcpip(), setnagle(), tcpconnected(), alder32(), getmacaddress(), iptouint(), uinttoip(), netconnected()
  • no udpconnect() - it's replaced by GM native UDP socket + sendmessage_udp(socket, ip, port, ...)
  • no bufferencrypt(), bufferdecrypt() but if you reeaaaly need it: Reading old encoded files
  • no fileopen, fileclose, filewrite, fileread, filepos, filesetpos, filesize - as most of them can be done with native GM buffer functions, or with existing a'la 39dll functions
  • no md5string(), md5buffer()
  • no dllinit(), dllfree() ;)
  • if you read more data than buffer, game will crash. I may try to add checking for reading more data than buffer have, but I need to make benchmarking first to ensure it's worth.

Functions from 39dll which are there

  • clearbuffer() - it clears global.buffer (or any other given buffer), same as 39dll was doing it
  • sendmessage(socket) - it sends data from buffer to selected socket
  • writebyte()/readbyte() - same as in 39dll it writes/read UNSIGNED 1-byte (8-bit) - 0 - 255
  • writeXXXX()/readXXXX() - same as in 39dll it writes/read SIGNED data, where XXXX is:
    • short - 2-bytes integer -32_768 to +32_767
    • int - 4-bytes integer -2_147_483_648 to +2_147_483_647
    • float - 4-bytes decimal number ~ -16_777_216.0 to +16_777_216.0
    • double - 8-bytes decimal number
  • writeuXXXX()/readuXXXX() - same as in 39dll it writes/read UNSIGNED data, where XXXX is:
    • short - 2-bytes integer 0 to +65_536
    • int - 4-bytes integer 0 to +4_294_967_296
  • writestring()/readstring() - for writing/reading strings, which are terminated with null-termiated aka 0b0000_0000 aka 0x00
  • writechars()/readchars() - for writing/reading strings, but not terminated, so you need to know their length when reading (or add it to a buffer... which makes them less useful than null-terminated ones, except sending just few letters)
  • getpos() - returns position in buffer (alias to buffer_tell())
  • setpos() - sets position in buffer (alias to buffer_seek())
  • buffsize() - gets size of buffer (alias to buffer_get_size())
  • bytesleft() - returns how many bytes left until end of buffer

New functions

  • seize_buffer - to copy async_load[? "buffer"] into global.buffer
  • write_sbyte()/read_sbyte() - as for byte, 39dll by default was reading/writing UNSIGNED numbers, and for others SIGNED so they have theur u versions to write/read unsigned number too, I wanted to add sth similar for bytes to write signed numbers < 0 and >= 128. I choose to add underscore in those function names, as writesbyte/readsbyte would just sound like plural version of their names. Also, since 39dll didn't followed rules for this one function, why should I? ;)