Networking - JakeTurner616/pygame-lua-bindings GitHub Wiki

Python networking functions

http_get(url)

Send an HTTP GET request to the specified URL.

Parameters:

  • url: The URL to send the GET request to.

Returns: The response text if the request is successful, otherwise the error message.

create_socket()

Create a new TCP/IP socket.

Returns: A new socket object.

connect_socket(sock, host, port)

Connect a socket to the specified host and port.

Parameters:

  • sock: The socket object to connect.
  • host: The hostname or IP address to connect to.
  • port: The port number to connect to.

Returns: True if the connection is successful, otherwise the error message.

send_socket(sock, data)

Send data through the socket.

Parameters:

  • sock: The socket object to send data through.
  • data: The data to send (as a string).

Returns: True if the data is sent successfully, otherwise the error message.

receive_socket(sock, buffer_size)

Receive data from the socket.

Parameters:

  • sock: The socket object to receive data from.
  • buffer_size: The maximum amount of data to receive at once.

Returns: The received data as a string if successful, otherwise the error message.