[Beowulf] Re: beowulf

Robert G. Brown rgb at phy.duke.edu
Mon Mar 8 14:44:50 EST 2004


On Mon, 8 Mar 2004, prakash borade wrote:


> how should i proceed for a client which takes dta from 5 servers
> reoetadly after every 15 seconds

> i get the data but it prints the garbage value
> 
> what can be the problem  i am usiung sockets on redhat 9
> 
> i am creting new sockets for it every time on clien side

Dear Prakash,

There is such a dazzling array of possible problems with your code that
(not being psychic) I cannot possibly help you.

For example -- 

  You could be printing an integer as a float without a cast (purely
misusing printf).  Or vice versa.  I do this all the time; it is a
common mistake.

  You could be sending the data on a bigendian system, receiving it and
trying to print it on a littleendian system.

  You could have a trivial offset wrong in your receive buffers --
printing an integer (for example) starting a byte in and overlapping
some other data in your stack would yield garbage.

  You could have a serious problem with your read algorithm.  Reading
reliably from a socket is not trivial.  I use a routine that I developed
over a fairly long time and it STILL has bugs that surface.  The
reading/writing are fundamentally asynchronous, and a read can easily
leave data behind in the socket buffer (so that what IS read is
garbage).

...and this is the tip of an immense iceberg of possible programming
errors.

The best way to proceed to write network code is to

  a) start with a working template of networking/socket code.  There are
examples in a number of texts, for example, as well as lots of
socket-based applications.  Pick a template, get it working.

  b) SLOWLY and GENTLY change your working template into your
application, ensuring that the networking component never breaks at
intermediary revisions.

or

  c) learn, slowly, surely, and by making many mistakes, to write socket
code from scratch without using a template.

Me, I use a template.

   rgb

P.S. to get more help, you're really going to have to provide a LOT more
detail than this.  Possibly including the actual source code.

-- 
Robert G. Brown	                       http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb at phy.duke.edu



_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list