import net
var data:array[0..87,int8]
var s = newSocket()
s.connect("localhost", Port(8000), 5000) # runs well.
var r = s.send(addr(data), len(data))
s.close()
How do I write the connection function with a ip ?
Accessibility as "localhost" is not the same as the IP. Try 127.0.0.1 as IP in your code. I just checked that IPs work as you specify it.
import net
var s = newSocket()
s.connect("173.194.112.119", Port(80), 5000)
#s.connect("localhost", Port(80), 5000)
s.send("GET / HTTP/1.0\nhost: www.google.de\n\n")
var
rc = ""
r = s.recv(rc, 100_000)
echo r
echo rc
s.close()
Thanks for OderWat!
I have closed all the firewall. And Python can't connect,too. But "127.0.0.1" can connect.