0

This is my code:

socket = require('socket')
conn = socket.connect('http://chat.freenode.net', 6667)
if conn == true then
print('connected') else
print('error') end

I even tried to put http in the url but it doesn't work

1 Answers1

0

If you get the error message (the second returned value), it should be fairly self-explanatory:

local socket = require('socket')
local conn, err = socket.connect('http://chat.freenode.net', 6667)
print(conn, err)

This prints nil "host or service not provided, or not known", because the URL you provided includes the scheme, which is not needed in this case. Try:

local conn, err = socket.connect('chat.freenode.net', 6667)
print(conn, err)

This should print something like "tcp{client}: 05EBB998".

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56