Failed to create socket


#1

The robot failed to create socket and reture 2, is there any problem with my code?

local ip="127.0.0.1"
local port=6000
local err=0
local socket=0
err, socket = TCPCreate(true, ip, port)
print(err)

err = TCPStart(socket, 0)

if err==0 then 
local data
	while true do
		err, RecBuf = TCPRead(socket,0,"string")
		data=RecBuf.buf    		
	  end
end