Subj : WinSock To : Jon Justvig From : Digital Man Date : Wed Jun 13 2018 12:24 pm Re: WinSock By: Jon Justvig to Digital Man on Wed Jun 13 2018 04:29 am > Re: WinSock > By: Digital Man to Jon Justvig on Tue Jun 12 2018 05:29 pm > > >> char buffer[20]; > > > >>> int result; > > > >>> // our recv loop > > >>> while (true) > > >>> { > > > >>> result = recv(current_client, buffer, sizeof(buffer), 0); // recv > > >>> cmds > > > >>> Sleep(10); > > > >>> if (result > 0) > > >>> { > > >>> cout << "\n\tMessage from client: " << buffer; > > >>> send(current_client, (const char*)buffer, sizeof(buffer), 0); > > >>> } > > > just above int result; ... > > DM> So.. if you only receive 2 bytes (result == 2), you're still going to > DM> send 20 (sizeof buffer)? That's probably not what you want. > > How might I receive between 2 and 12 bytes? You're calling recv() with a max-length of 20 (sizeof buffer). That doesn't mean you'll necessarily receive exactly 20 bytes. You could receive anywhere between 0 and 20 bytes - the return value of recv() tells you how many bytes you received, if any. digital man This Is Spinal Tap quote #7: Nigel Tufnel: That's just nitpicking, isn't it? Norco, CA WX: 87.0øF, 41.0% humidity, 5 mph NE wind, 0.00 inches rain/24hrs --- þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net .