#include "net_mod_socket.h" #include "socket_io.h" #include "net_mod_socket_io.h" NetModSocket::NetModSocket(const char *host, int port) { char portstr[32]; sprintf(portstr, "%d", port); clientfd = Open_clientfd(host, portstr); Rio_readinitb(&rio, clientfd); } ssize_t NetModSocket::send(void *buf, size_t size) { int n = rio_writen(clientfd, buf, size); rio_writen(clientfd, PKG_SEP, strlen(PKG_SEP)); char resp[MAXLINE]; int ss; ss = rio_readpkgb(&rio, resp, MAXLINE); puts(resp); return n; } // ssize_t recv(void *buf, size_t len) { // return rio_readlineb(&rio, buf, MAXLINE); // } NetModSocket::~NetModSocket() { Close(clientfd); }