#include #include #include #include #include "net.h" bool net_send_raw_text(int fd,const char *text,i64 len){ i64 cursor=0; while(cursor0){ i64 bufsz=64; buf=malloc(bufsz,char); for(i64 i=0;i=bufsz){ bufsz=len+512; buf=realloc(buf,bufsz,char); } memcpy(buf+1,list[i],len); buf[0]=' '; if(net_send_raw_text(fd,buf,len+1)){ free(buf); return true; } } free(buf); } return net_send_raw_text(fd,"\n",1); } bool net_send_pong(int fd,const char *tag){ char *buf=NULL; i64 len=asprintf(&buf,"%s pong\n",tag); bool closed=net_send_raw_text(fd,buf,len); free(buf); return closed; }