Sending struct through DGRAM socket

Greg Economides greg at carnivore.tamu.edu
Fri Apr 19 01:35:05 AEST 1991


I am trying to communicate with a forked process using a DGRAM socket
(AF_UNIX) on a Sun 386i (OS 4.0.2).  What I really want to send through
the socket is a small struct (about five float fields).  I have been
using the `sendto' and `read' functions which need a (char *) to send
through the socket.  These work fine with character strings, but do not
do so well with structs.

Is there a quick/clean way to translate a struct into a character stream 
(and then a way to get the struct back) so that it can be sent using these
functions?  Is there a better or more straight-forward way of doing this?
I am still quite a fledgling sockets programmer.

Thanks for any and all help.  I will summarize the responses if there is
interest.

Peace,
--
Greg Economides                          "This sentence is false" 
Technical Lab Coordinator 
Texas A&M University -- Biosystems Modelling Group
Internet: greg at carnivore.tamu.edu



More information about the Comp.unix.programmer mailing list