[vox-tech] TCP and Linux

Mike Simons vox-tech@lists.lugod.org
Tue, 15 Apr 2003 12:55:25 -0400


--2fjX3cMESU3XgGmZ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Apr 15, 2003 at 09:04:57AM -0700, Rod Roark wrote:
> On Tuesday 15 April 2003 08:38 am, Mike Simons wrote:
> > On Mon, Apr 14, 2003 at 09:13:55PM -0700, Rod Roark wrote:
> > > Someone I know runs a game server daemon but doesn't have
> > > the source for it.  It has a bug that I suspect comes from
> > > doing send() calls to a nonblocking socket without checking
> > > for a buffer-full condition.  Therefore some sent data is
> > > lost.
> >
> > - Is the binary dynamicly linked against libc.so?
> >   (send output from ldd /path/to/binary)
>=20
> Um, probably as that's the compiler default.  Email turnaround
> from this admin is a bit slow.  Where is this question headed?
> I don't think a suggestion of recompiling glibc will get far.
> :-)

  It is not too tricky to write a little C code which pretends to be
libc for the functions socket/connect/send, which acts as a wrapper for
the around the real functions... doing a little book keeping and then
calling the real libc functions.

  You put this library in your LD_LIBRARY_PATH or LD_PRELOAD environment
variables before running the binary in question and you can replace those=
=20
system calls with whatever you want.  In reality you would run setsockopt=
=20
calls to increase the buffer and maybe do something fancy if the send=20
call returns a partial write.

  I've taken this approach to work around a few bugs in a Oracle OCI=20
library that the development team at Oracle decided not to fix.

I can put together an example snip of code ...=20
- explain what you want done at socket creation time?=20
  (are sockets incoming or outgoing)
- what do you want done if send a partial buffer happens?
  (queue on a buffer to send next before send, block waiting for
   send to work, return error, etc...)

--=20
GPG key: http://simons-clan.com/~msimons/gpg/msimons.asc

--2fjX3cMESU3XgGmZ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+nDl94Qwkn7f6rL4RAqw7AJwJHnIySNmhIRACAo7zlIU6o5UglwCglUeK
Nyd1+wlgvot7/L0muZF02Fs=
=xZ+s
-----END PGP SIGNATURE-----

--2fjX3cMESU3XgGmZ--