$ git clone http://tcclient.ion.nu/tc_client.git
commit 6a9b1204dfba981b258e17eb1cb5632f7b31da51
Author: Alicia <...>
Date:   Wed Mar 8 11:41:41 2017 +0100

    Bugfix: exit with non-zero status if connection fails.

diff --git a/ChangeLog b/ChangeLog
index f12c3fa..d307a7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ Fixed tinychat account support.
 Call curl_easy_cleanup() at the end of the session to make sure cookies get written.
 Adjusted tinychat account support for the latest compatibility-breaking changes.
 Added workaround in the RTMP acknowledgement code for when 4 gigabytes of data has been sent and the 32bit integer rolls around to 0.
+Bugfix: exit with non-zero status if connection fails.
 modbot: use https instead of http and use the tcclient subdomain since some DNSes have trouble with underscores.
 modbot: added an option (--no-unapproved) to not add any unapproved videos to queue (videos still get approved by mods requesting or playing them manually)
 tc_client-gtk: fixed a race-condition in the builtin video player.
diff --git a/client.c b/client.c
index 65f197e..05da253 100644
--- a/client.c
+++ b/client.c
@@ -265,6 +265,7 @@ int main(int argc, char** argv)
   {
     sock=init_kageshicam(&site);
   }
+  if(sock==-1){return 1;}
   free(account_pass);
   int random=open("/dev/urandom", O_RDONLY);
   if(currentcolor>=COLORCOUNT)
diff --git a/kageshi.c b/kageshi.c
index 5e4b307..37f1f6f 100644
--- a/kageshi.c
+++ b/kageshi.c
@@ -1,6 +1,6 @@
 /*
     tc_client, a simple non-flash client for tinychat(.com)
-    Copyright (C) 2016  alicia@ion.nu
+    Copyright (C) 2016-2017  alicia@ion.nu
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU Affero General Public License as published by
@@ -267,6 +267,7 @@ int init_kageshi(const char* chanpass, const char* username, const char* userpas
   site->camup=notimplemented;
   site->camdown=notimplemented;
   int sock=connectto("107.191.96.85", "1935");
+  if(sock==-1){return -1;}
   rtmp_handshake(sock);
   // Send connect request
   struct rtmp amf;
@@ -416,6 +417,7 @@ int init_kageshicam(struct site* site)
   site->camup=notimplemented2;
   site->camdown=notimplemented2;
   int sock=connectto(server, "1935");
+  if(sock==-1){return -1;}
   rtmp_handshake(sock);
   // Send connect request
   struct rtmp amf;
diff --git a/tinychat.c b/tinychat.c
index e0792e5..98b3a64 100644
--- a/tinychat.c
+++ b/tinychat.c
@@ -733,6 +733,7 @@ int init_tinychat(const char* chanpass, const char* username, const char* userpa
   port[0]=0;
   ++port;
   int sock=connectto(server, port);
+  if(sock==-1){return -1;}
 
   rtmp_handshake(sock);
   if(!loggedin){username=0; userpass=0;}