📄 network.pc
字号:
// network sample
#include "../UtilCode/neterror.h"
@doc "send a string on a socket";
socksends(int id, string s) {
return socksend(id, &s, "s", 1);
}
main() {
int err, s;
string name, addr, index;
err = netopen();
if (err == 0) {
puts("[" + netlocaladdr() + "]\n");
if (0 == nethostbyname("www.orbworks.com", &addr)) {
if (0 == sockopen(&s)) {
if (0 == sockconnect(s, addr + ":80")) {
socksends(s, "GET /index.html HTTP/1.0\n\n");
sockrecv(s, &index, "s", 1);
index = strleft(index, 135);
puts("index.html:\n" + index + "\n");
}
sockclose(s);
}
}
netclose();
} else {
puts("Failed to open network: " + neterror(err) + "\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -