From 5306a2195107027a33777c97e6fbc8ffecfbc25c Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 10 Nov 2020 21:20:28 +0100 Subject: Oops, I'm dumb I believe I was wrong in my previous commit message. Let's see... --- kernel/features/net.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'kernel') diff --git a/kernel/features/net.c b/kernel/features/net.c index 3c1d620..eb22afc 100644 --- a/kernel/features/net.c +++ b/kernel/features/net.c @@ -10,6 +10,7 @@ #include #include #include +#include static u32 current_ip_addr = ip(10, 0, 2, 15); static u32 gateway_addr = 0; @@ -630,8 +631,11 @@ int net_connect(struct socket *socket, u32 ip_addr, u16 dst_port) tcp_send_packet(socket, TCP_FLAG_SYN, NULL, 0); struct tcp_socket *tcp = &socket->prot.tcp; sti(); - while (tcp->state != 3 && tcp->state != 5) - ; // TODO: Timeout + u32 time = timer_get(); + while (tcp->state != 3 && tcp->state != 5 && timer_get() - time < 1000) + ; + if (tcp->state != 3 && tcp->state != 5) + return 0; } else { return 0; } @@ -668,7 +672,7 @@ void net_install(void) if (net_connect(socket, ip(10, 0, 0, 33), 80)) net_send(socket, strdup(http_req), strlen(http_req)); else - print("Something went wrong!\n"); + print("Couldn't connect!\n"); // Server // TODO: Serve using sockets /* struct socket *socket2 = net_open(S_TCP); */ -- cgit v1.2.3