src/ATEASerif_English/atea-server.cpp
// read from the socket up to the first space

read from the socket up to the first space
read from the socket up to the first space
int readCommandSize(SOCKET &sock, char *buf, int max_length) {
	int i = 0;
	char recvbuf[2];
	int iResult;
	char c;
	do {
		iResult = recv(sock, recvbuf, 1, 0);
		c = recvbuf[0];
		if (i >= max_length) {
			return 1;
		}
		buf[i++] = c;
	} while (c != ' ');
	buf[i-1] = '\0';
	if (atoi(buf) == 0) return 1;
	return 0;
}
int readCommandSize ( SOCKET & sock , char * buf , int max_length ) { int i = 0 ; char recvbuf [ 2 ] ; int iResult ; char c ; do { iResult = recv ( sock , recvbuf , 1 , 0 ) ; c = recvbuf [ 0 ] ; if ( i >= max_length ) { return 1 ; } buf [ i ++ ] = c ; } while ( c != ' ' ) ; buf [ i - 1 ] = ' \0 ' ; if ( atoi ( buf ) == 0 ) return 1 ; return 0 ; }
read from the socket up to the first space
read from the socket up to the first space
// grab one character at a time until you see a space
 // write over the final space with a terminator
