mawinkle 6 tahun lalu
induk
melakukan
0ce1b7f686
2 mengubah file dengan 5 tambahan dan 5 penghapusan
  1. 2 2
      socketio_posix.cpp
  2. 3 3
      test.cpp

+ 2 - 2
socketio_posix.cpp

@@ -74,13 +74,13 @@ void cppsocket::write(const std::vector<char>& message){
 		if((i + buffersize) < message.size()){
 			cs[buffersize] = 'c';
 			if(send(sock, cs, buffersize + 1, 0) < 0){
-				throw socket_exception("Couldn't write to peer");
+				throw socket_exception(std::string("Couldn't write to peer: ") + strerror(errno));
 			}
 		}
 		else{
 			cs[message.size() - i] = (char)0;
 			if(send(sock, cs, message.size() - i, 0) < 0){
-				throw socket_exception("Couldn't write to peer");
+				throw socket_exception(std::string("Couldn't write to peer: ") + strerror(errno));
 			}
 		}
 	}

+ 3 - 3
test.cpp

@@ -21,11 +21,11 @@ std::ostream& operator<< <char>(std::ostream& out, std::vector<char> o){
 	return out;
 }
 int main(){
-	cppsocket sock("192.168.178.79", 80);
-	//cppsocket sock("127.0.0.1", 80);
+	//cppsocket sock("192.168.178.79", 80);
+	cppsocket sock("127.0.0.1", 80);
 	std::vector<char> toSend(10000);
 	for(unsigned int i = 0;i < toSend.size();i++){
-		toSend[i] = (char)(i * i);
+		toSend[i] = (char)(i * i) % 10 + 'a';
 	}
 	std::cout << "Writing..." << std::endl;
 	//std::cout << errno << std::endl;