[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Re: perl help



Hi all,

	Thanks sreeji, for the help..
			Well my problem is that the other part was written in
java(java application), and actually i am writing a cgi
script which suppose to talk to the java application over
udp(bluetooth interface).

since i can't change the way the java application was
written, all i can do is change my code.

i need to form packet of 3 bytes , containing 1 byte of
operation code and rest two byte for data.
similarly i get 3 bytes packet from the other side
containing status info.

the problem starts  here, if i  send op code 1 it reaches
there as 48,  same thing happen with data,
but now i found out that when i send \1  it reaches ther
as 1, but still i am unable to figure out how to send the
twobyte data,
for reciving..also i am facing the same problem..all i am
reciving is all junk character.

I hope this explanation is ok, please help me
out...really got struct..doing all sort of permutation
and combination..nothings seems to work...

TIA
/moyukh




			

------------- Original Message --------------

On 13 Jan 2001, Moyukh wrote:

> Hi all,
> 		well i am new to perl programming..i am trying out some
> socket programming..
> when i send 0 (zero) it reaches as ascii zero that is 48,
> even if i try to send 0x0 then also it goes as ascii zero.
>
> what ever i send it all goes as ascii, the second
problem is
> how to cover the data recived as ascii character to int....
>
Well, in perl the difference between a character & an
interger is
dim. Perl treats them appropriately based on the context.
So you can have
statements like

$String = "1000"; $String++;
print "$String\n";

During the string assignment, 1000 is considered as a
string. But the ++
operator treats it as a number, without you explicitly
specifying
anything.

Now, coming to your problem, what exactly is your
requirement ? Why do u
want to convert from ascii 2 integer ..? You can simply do a
syswrite() on one end (or send() if u're using UDP) &
sysread (or recv) on
the other end. U'll always get the same data. Socket
programming in perl
is damn easy, if u use the standard modules, such as
IO::INET::Socket.
If u want I can send u sample code.

Sreeji



---------------------------------------------
Find out more about this and other Linux India
mailing lists at http://lists.linux-india.org/

_____________________________________________________
Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com