Re: Simple socket conumdrum

From: dar7yl (no_reply_at_accepted.org)
Date: 01/20/05


Date: Thu, 20 Jan 2005 07:16:41 GMT


> When I bump up to 102400 bytes, it hangs about 70% of the way into the
> total
> amount, meanwhile the client thinks that it has completed sending the data
> and is awaiting acknowledgment from the server.

It sounds like the http socket is timing out.
Try turning off buffering for the output, and write a block at a time.
 (btw, I didn't see anywhere you are actually writing the data to the
client)

as a matter of style, recode your loop as follows:
(the brace style is your own preference, I abhor K&R style)
<code>
  int remainder = totalCnt;
  while (remainder > 0)
  {
     int amtToRead = remainder ;
     if (amtToRead > BLOCKSIZE)
    {
         amtToRead = BLOCKSIZE;
    }
    int amtRcvd = is.read(buffer, 0, amtToRead);
    remainder -= amtRcvd;

    // now, what are you doing with your buffer here?
  } // while
</code>

regards,
    Dar7yl

"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;
> }
>
> For a small amount of data, 10240 bytes, this works fine.
>
> When I bump up to 102400 bytes, it hangs about 70% of the way into the
> total
> amount, meanwhile the client thinks that it has completed sending the data
> and is awaiting acknowledgment from the server.
>
> If I kill the client at this point, then the sockets are closed and I get
> an
> appropriate exception on the server.
>
> Finally, running the client and server on my windows machine, it works
> (though it is not consistent). It consistently fails with the server on a
> Solaris 8 machine.
>
> Anyone have any hints why this is hanging up?
>
> Thanx!
>
> Regards,
>
> Will Hartung
> (willh@msoft.com)
>
>



Relevant Pages

  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)
  • This is going straight to the pool room
    ... or not the client has privilege to do what they're trying to do, ... The server environment is this: ... 3GL User action Routines that Tier3 will execute on your behalf during the ... Routine Name: USER_INIT ...
    (comp.os.vms)
  • [Full-Disclosure] R: Full-Disclosure Digest, Vol 3, Issue 42
    ... Full-Disclosure Digest, Vol 3, Issue 42 ... SD Server 4.0.70 Directory Traversal Bug ... Arkeia Network Backup Client Remote Access ...
    (Full-Disclosure)
  • Re: What doesnt lend itself to OO?
    ... > rather than client code. ... no way to do that without also touching the object with clock semantics ... will not encapsulate both clock semantics and network semantics. ... The server can do whatever it wants ...
    (comp.object)
  • RE: Fax monitor incoming + outgoing calls?
    ... problem between the client computer and the SBS server. ... Client is using the internal IP address of the SBS server as the ... To the folder redirection GPO issue: ...
    (microsoft.public.windows.server.sbs)