mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 14:58:27 +00:00
wip: Http Client experiments
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
add_executable(ChatClient ChatClient.cpp)
|
||||
target_link_libraries(ChatClient raknet dCommon)
|
||||
|
||||
add_executable(ChatHttpClient ChatHttpClient.cpp)
|
||||
target_link_libraries(ChatHttpClient raknet dCommon)
|
||||
|
32
dChatClient/ChatHttpClient.cpp
Normal file
32
dChatClient/ChatHttpClient.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <TCPInterface.h>
|
||||
#include <HTTPConnection.h>
|
||||
#include <RakSleep.h>
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
std::cout << "Hello World!" << std::endl;
|
||||
|
||||
TCPInterface tcp;
|
||||
if (!tcp.Start(0, 0)) {
|
||||
std::cerr << "Failed to start TCP Interface" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SystemAddress addr = tcp.Connect("127.0.0.1", 8000);
|
||||
std::cout << "addr: " << addr.ToString() << std::endl;
|
||||
|
||||
std::string req = "\
|
||||
GET /helloFromRakNet.txt HTTP/1.1\r\n\
|
||||
User-Agent: raknet / 3.25\r\n\
|
||||
\r\n";
|
||||
std::cout << req;
|
||||
|
||||
tcp.Send(req.c_str(), req.size(), addr);
|
||||
|
||||
RakSleep(500);
|
||||
|
||||
tcp.CloseConnection(addr);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user