Hi Caius,
check the z return value of read(). It should be 4 and then
do something like buf[z] = 0; before printing. SendRaw() does not
add any extra data. Also you are responsible for byteswapping.
Cheers, Fons.
Caius Howcroft wrote:
>
> Hi,
>
> I am trying to get a process running root sockets to talk to a
> regular socket server, ie "sys/socket.h".
>
> I want to send an integer, either by sending it directly or by sending it
> as a char array.
>
> in the root client:
> char str[]="5467"
> void *buffer;
> Int_t thesize= sizeof(buffer);
> sock->SendRaw(buffer, thesize);
>
> in the c-socket server:
>
>
> struct sockaddr_in cin;
> struct sockaddr_in sin;
> struct hostent *hp;
> unsigned int *buffer;
> unsigned int sd, sd_client, addrlen, a;
> char str[1];
> char buf[8];
> int z;
> printf("MBRP(fake):Starting....\n");
> memset(&sin,0,sizeof(sin));
> sin.sin_family = AF_INET;
> sin.sin_addr.s_addr = INADDR_ANY;
> sin.sin_port = htons(PORT);
> sd = socket(AF_INET,SOCK_STREAM,0)
> bind(sd,&sin,sizeof(sin)
> listen(sd,queuesize)
> while (true)
> {
> sd_client = accept(sd,&cin,&addrlen)
> z = read(sd_client, buf, sizeof buf);
> printf("MBRP(fake):Read %s from buffer", buf);
>
> close (sd_client);
> }
> close (sd);
>
> My question is, does the root SendRaw fuction work in the same manner as
> writing (using write) to a c-socket file descriptor. If so why do I
> receive
>
> Read 5467d&`@o from buffer
>
> How do I get it to just read the thing I send? it lookslike its reading
> extra memory, or are root messages padded with root info?
>
> cheers
> Caius
>
> ___
>
> ___________________
> CAIUS HOWCROFT
> 01223 711 788 UK
> 07977 473 937 UK(mobile)
--
Org: CERN, European Laboratory for Particle Physics.
Mail: 1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:35 MET