[ROOT] sending ints from root sockets to c-sockets.

From: Caius Howcroft (howcroft@hep.phy.cam.ac.uk)
Date: Wed Feb 07 2001 - 17:52:58 MET


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)



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:35 MET