1234567891011121314151617181920212223242526272829303132333435 |
- #include "socketio.hpp"
- #include <iostream>
- #include <exception>
- template<typename T>
- std::ostream& operator<<(std::ostream& out, std::vector<T> o){
- out << "(";
- for(unsigned int i = 0;i < o.size();i++){
- if(o[i] == '\r')continue;
- out << o[i];
- if(i < (o.size() - 1))
- out << ", ";
- }
- return out << ")";
- }
- template<>
- std::ostream& operator<< <char>(std::ostream& out, std::vector<char> o){
- for(unsigned int i = 0;i < o.size();i++){
- out << o[i];
- }
- return out;
- }
- int main(){
- server_socket ssock(80);
- while(true){
- cppsocket sock = ssock.accept_connection();
- try{
- std::vector<char> vec = sock.receive();
- sock.write("Hallo\n");
- sock.close();
- }
- catch(std::exception& e){
- std::cout << e.what() << std::endl;
- }
- }
- }
|