Guest User

Don

a guest
Mar 10th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Lua socket:
  2. local socket = require("socket")
  3. local server = assert(socket.bind("127.0.0.1", 3335))
  4. local ip, port = server:getsockname()
  5. print("Socket started and now accepting connection")
  6. local client = server:accept()
  7. print("Connected!")
  8. while 1 do
  9. local line, err = client:receive()
  10. if not err then print(line) end
  11. end
  12.  
  13. Actionscript (just the importan parts):
  14.  
  15. public var socket:Socket = new Socket("127.0.0.1",3335);
  16. socket.addEventListener(Event.CONNECT,sockOnConnect);
  17. public function sockOnConnect(e:Event):void {
  18. socket.writeUTF("\r\nHello world\r\n");
  19. }
  20. stage.addEventListener(MouseEvent.click,sendMessage);
  21. public function sendMessage(e:MouseEvent):void {
  22. trace("Mouse click detected, now sending message");
  23. socket.writeUTF("\r\nTest message\r\n");
  24. }
  25.  
  26. Problem:
  27. Actionscript only sends the first message (Right after connection)
  28. But afterwards, when the mouse click is detected, those messages aren't being sent..
  29. The connection is not lost by the way, just letting you know
Advertisement
Add Comment
Please, Sign In to add comment