gm_glsock - Listen for UDP Packets

Hello. I need help with the gm_glsock module. (http://www.facepunch.com/threads/1136961)

I am looking for some example code to look at, because that is how I learn.

What I am trying to make is a simple script that will run in Garry’s Mod and listen for UDP packets on a given port. I would like to print the data of the packets.

I have tried some things with the module but they either did nothing, or crashed Garry’s Mod.

I will paste what I have so far (even though it is probably useless). My code is most likely awful but I am lost.

I don’t know the forum post tags for lua code. D:

// Code
**require(‘glsock’)

	function ErrorCB(handle, err)
		print(err)
	end

	MySock = GLSock(GLSOCK_TYPE_ACCEPTOR)

	MySock.Bind("127.0.0.1", 6969, ErrorCB(handle, err))

	MySock.Listen(10, ErrorCB)**

//

I do not know what to add / change. Please help.

Thank you.

Post this in the glsock thread instead.