Re: Simple socket conumdrum

From: Matt Humphrey (matth_at_ivizNOSPAM.com)
Date: 01/20/05


Date: Thu, 20 Jan 2005 15:51:41 -0500


"Will Hartung" <willh@msoft.com> wrote in message
news:3589j5F4jmle4U1@individual.net...
> I have a brain dead Client and equally unsophisticated Server program.
>
> The Client connects to the Server, server pops a thread, and then they
have
> a simple conversation.
>
> The basic goal of the C/S system is simply to Move Data in order to
evaluate
> timings and what not for a project.
>
> I don't care WHAT the data is, I just want to move some.
>
> Here's the meat of the Server:
>
> I get the InputStream using:
>
> InputStream is = socket.getInputStream();
>
> My blocksize is 8192.
>
> Then, I run this little loop:
> while(totalRcvd != totalCnt) {
> int amtToRead = blocksize;
> if (amtToRead > (totalCnt - totalRcvd)) {
> amtToRead = totalCnt - totalRcvd;
> }
> int amtRcvd = is.read(buffer, 0, amtToRead);
> totalRcvd = totalRcvd + amtRcvd;
> }

Just for completeness sake, are you sure you set totalRcvd to 0 after each
message? Also, how is totalCnt count assigned? Are you sure it's the same
for both? (e.g. is it sent as a 2-byte prefix or a 4-byte prefix?) Is the
data being sent as bytes (not characters) down a corresponding Output
Stream?

Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/



Relevant Pages

  • Re: Cant use "www" url to webserver on LAN?
    ... "Rich Grise" wrote in ... > presumably because that's what the server calls itself. ... prefix "mail", and the prefix "ftp" all point to my current IP. ... There is another option in that the modem will also offer an IP ...
    (comp.os.linux.networking)
  • Re: Mail.app und IMAP
    ... dass das Prefix stimmt (es ist ein courier IMAP ... server, das Prefix ist auf INBOX gestellt). ...
    (de.comp.sys.mac.internet)
  • Re: URL
    ... paste that into an IE Address bar, replace the mailto: prefix ... with a news: prefix, then try that. ... if that news.free.fr is not your default server and the ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Mutex not working as expected
    ... if you use the Global\ prefix the first one in (Admin ... I'm curious if this is a feature of XP, of XP Pro, or of SP2. ... Its really annoying that it appears that Terminal Server itself follows one ... I would expect a Mutex with vBool = false... ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Mutex not working as expected
    ... >> Mutex's are global to the system unless you specify the Local\\ prefix ... > I get the impression it is true on server side for server ... On previous windows versions, there was no fast user switching, so you ... Tom Shelton ...
    (microsoft.public.dotnet.languages.vb)