- Joined
- Nov 24, 2014
- Messages
- 3,162
- Trophies
- 2
- Age
- 29
- Location
- Bologna
- Website
- rinnegatamante.it
- XP
- 4,858
- Country
Good to know and helpful, changes the way I code most of this, but I seem to still have the same problem.
Made some basic test code, ran by itself, to try to isolate the problem.
Code:Socket.init() client = 0 while client == 0 do client = Socket.connect("192.168.1.201", 6667) end Socket.send(client, "TEST") Socket.close(client) Socket.term() while true do if Controls.check(Controls.read(), KEY_START) then System.exit() end end
Behavior seems to depend on lpp-3ds version.
On R4 and the november nightly:
Error: [string "?"]:4: Failed connecting server.
However, on current git:
Error: [string "?"]:6: bad argument #1 to 'send' (number expected, got nil)
This seems to imply that if it can't connect, as of the current git instead of throwing up an error it returns nil. Which is handy, but if I test for that then I just get to debugprint my own way of saying "Connection failed."
On the receiving end, I occasionally get half-open connections which cause netcat to quit as though something connected to it and then left, but mostly seem to get nothing.
Since I did get the net_request_string sample working, I decided to try this just once, seeing as it's contacting the same server:
Code:Socket.init() client = 0 while client == 0 do client = Socket.connect("rinnegatamante.netsons.org", 80) end Socket.send(client, "GET /\r\n") Socket.close(client) Socket.term() while true do if Controls.check(Controls.read(), KEY_START) then System.exit() end end
Exact same result, either "Failed connecting server" or an attempt to send to a nil socket, depending on lpp-3ds version.
There isn't a DNS resolver right now for hostnames resolutions. Try to change the while loop condition from client == 0 to client == nil