Network Module

From SolarStrike wiki
Jump to: navigation, search

See also: Socket Class

Network Events

Due to the asynchronous nature of networking, a lot of networking information will only be available through the event system. For example, when a socket receives data, a new event will be pushed that contains the socket ID and the contents of the message.

Relevant events are: socketconnected, socketdisconnected, socketreceived, and socketerror. For a full description of of these events, see the Events page. The important thing to remember is that the socketconnected event will push a new socket object while other socket events will only push a socket ID. As such, you should be sure to save the new socket object (preferably into a table) if your script will be accepting new connections.


socket

socket network.socket([string "tcp"|"udp"])

Create a new socket object. This object will be used to actually open a connection and transmit data. Accepts only one string which determines the protocol type: "tcp" or "udp"; defaults to TCP if not given.