📄 tlsclient.cxx
字号:
#include <cstdio>#include "Tcp_ClientSocket.hxx"#include "TlsConnection.hxx"#include "cpLog.h"#include <stdio.h>int main(){ cpLogSetPriority(LOG_DEBUG_STACK);// TcpClientSocket f("www.fortify.net", 443); TcpClientSocket f("localhost", 4000); char buf[4096]; try { f.connect(); } catch (...) { cout << "failed to connect\n"; exit(-1); } try { string x = "STARTTLS\n"; f.getConn().writeData(x); int y; f.getConn().readLine(buf, 4095, y); cout << "return: " << buf; f.getConn().readLine(buf, 4095, y); cout << "return: " << buf; TlsConnection tls(f.getConn()); int err = tls.initTlsClient(); if(err > 0) { string out = "GET / HTTP/1.0\n\n"; tls.writeData(out); err = tls.readn(buf, 4095); buf[err] = '\0'; printf("%s", buf); } tls.close(); } catch(...) { cout << "no good!\n"; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -