diff options
author | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2010-10-02 11:19:52 +0200 |
---|---|---|
committer | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2010-10-02 11:19:52 +0200 |
commit | 01982930a4852345c3b54d2c82f5c5ae7a2d970f (patch) | |
tree | 47ace07615758a9eecb3738a7a7626d4713d03d4 | |
parent | b898569df5c7388500d76d9b96f9111ba09c2ff3 (diff) | |
download | MAC-Telnet-01982930a4852345c3b54d2c82f5c5ae7a2d970f.tar.gz MAC-Telnet-01982930a4852345c3b54d2c82f5c5ae7a2d970f.zip |
Send more than 1 byte at the time if more exists in the buffer
-rw-r--r-- | main.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -192,7 +192,7 @@ void handlePacket(unsigned char *data, int data_len) { int main (int argc, char **argv) { int insockfd; int result; - char data[200]; + char data[1500]; struct sockaddr_in si_me; char buff[1500]; int plen = 0; @@ -345,12 +345,14 @@ int main (int argc, char **argv) { handlePacket(buff, result); } if (FD_ISSET(0, &read_fds)) { - unsigned char key = getc(stdin); + unsigned char keydata[100]; + int datalen; + datalen = read(STDIN_FILENO, &keydata, 100); memset(data, 0, sizeof(data)); plen = initPacket(data, MT_PTYPE_DATA, srcmac, dstmac, sessionkey, outcounter); - outcounter ++; - memcpy(data + plen, &key, 1); - result = sendUDP(data, plen + 1); + outcounter += datalen; + memcpy(data + plen, &keydata, datalen); + result = sendUDP(data, plen + datalen); } } else { /* keepalive */ |