Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Lua socket:
- local socket = require("socket")
- local server = assert(socket.bind("127.0.0.1", 3335))
- local ip, port = server:getsockname()
- print("Socket started and now accepting connection")
- local client = server:accept()
- print("Connected!")
- while 1 do
- local line, err = client:receive()
- if not err then print(line) end
- end
- Actionscript (just the importan parts):
- public var socket:Socket = new Socket("127.0.0.1",3335);
- socket.addEventListener(Event.CONNECT,sockOnConnect);
- public function sockOnConnect(e:Event):void {
- socket.writeUTF("\r\nHello world\r\n");
- }
- stage.addEventListener(MouseEvent.click,sendMessage);
- public function sendMessage(e:MouseEvent):void {
- trace("Mouse click detected, now sending message");
- socket.writeUTF("\r\nTest message\r\n");
- }
- Problem:
- Actionscript only sends the first message (Right after connection)
- But afterwards, when the mouse click is detected, those messages aren't being sent..
- The connection is not lost by the way, just letting you know
Advertisement
Add Comment
Please, Sign In to add comment