hi
i want to send unsigned 32 bit integer to socket, and looking for
something equivalent to this method... http://livedocs.adobe.com/flex/2/lan...teUnsignedInt()
is there such method / library available in python?!
this is as far as i have gotten along
>>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1',3000))
4 4541 rk*****@gmail.com wrote:
hi
i want to send unsigned 32 bit integer to socket, and looking for
something equivalent to this method...
http://livedocs.adobe.com/flex/2/lan...teUnsignedInt()
is there such method / library available in python?!
this is as far as i have gotten along
>>>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1',3000))
You will need to use struct module to build the 4 byte value and then send it.
Something like (not tested):
import struct
us32bit = struct.pack("I", value)
s.send(us32bit)
-Larry
On Sun, Jul 27, 2008 at 7:01 PM, Larry Bates <la*********@websafe.com`wrote:
rk*****@gmail.com wrote:
>i want to send unsigned 32 bit integer to socket, and looking for something equivalent to this method... http://livedocs.adobe.com/flex/2/lan...teUnsignedInt()
is there such method / library available in python?!
You will need to use struct module to build the 4 byte value and then send
it.
Something like (not tested):
import struct
us32bit = struct.pack("I", value)
s.send(us32bit)
thanks a lot!!!
just to make sure if I want 32 bit or 4 bytes then should I use the
short or integer or long?
this is short
>>struct.pack('!h',3)
'\x00\x03'
this is integer
>>struct.pack('!i',3)
'\x00\x00\x00\x03'
this is long
>>struct.pack('!l',3)
'\x00\x00\x00\x03' rk*****@gmail.com wrote:
On Sun, Jul 27, 2008 at 7:01 PM, Larry Bates <la*********@websafe.com`wrote:
>rk*****@gmail.com wrote:
>>i want to send unsigned 32 bit integer to socket, and looking for something equivalent to this method... http://livedocs.adobe.com/flex/2/lan...teUnsignedInt()
is there such method / library available in python?!
You will need to use struct module to build the 4 byte value and then send it.
Something like (not tested):
import struct us32bit = struct.pack("I", value) s.send(us32bit)
thanks a lot!!!
just to make sure if I want 32 bit or 4 bytes then should I use the
short or integer or long?
this is short
>>>struct.pack('!h',3)
'\x00\x03'
this is integer
>>>struct.pack('!i',3)
'\x00\x00\x00\x03'
this is long
>>>struct.pack('!l',3)
'\x00\x00\x00\x03'
Short is 16 bits, Integer is 32 bits, long is 64 bits (as I read and have found).
-Larry
On Sun, Jul 27, 2008 at 7:17 PM, Larry Bates <la*********@websafe.com`wrote:
rk*****@gmail.com wrote:
>On Sun, Jul 27, 2008 at 7:01 PM, Larry Bates <la*********@websafe.com`> wrote:
>>rk*****@gmail.com wrote: i want to send unsigned 32 bit integer to socket, and looking for something equivalent to this method...
http://livedocs.adobe.com/flex/2/lan...teUnsignedInt()
is there such method / library available in python?!
You will need to use struct module to build the 4 byte value and then send it.
Something like (not tested):
import struct us32bit = struct.pack("I", value) s.send(us32bit)
thanks a lot!!!
just to make sure if I want 32 bit or 4 bytes then should I use the short or integer or long?
this is short
>>>>> struct.pack('!h',3)
'\x00\x03'
this is integer
>>>>> struct.pack('!i',3)
'\x00\x00\x00\x03'
this is long
>>>>> struct.pack('!l',3)
'\x00\x00\x00\x03'
Short is 16 bits, Integer is 32 bits, long is 64 bits (as I read and have
found).
thanks a lot!!! re-read it again!!!
from the struct doc!
Standard size and alignment are as follows: no alignment is required
for any type (so you have to use pad bytes); short is 2 bytes; int and
long are 4 bytes; long long (__int64 on Windows) is 8 bytes; float and
double are 32-bit and 64-bit IEEE floating point numbers,
respectively. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pointer noob |
last post by:
Hi,
I am trying to write a bit of code to iterate through memory addresses
and if the address is divisable by 2 then write one byte, if not write
a different byte. I am having trouble with the...
|
by: techie |
last post by:
I have defined a number of unsigned integer types as follows:
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedfe long long uint64;
Is it...
|
by: somenath |
last post by:
Hi All,
I am trying to undestand "Type Conversions" from K&R book.I am not
able to understand the
bellow mentioned text
"Conversion rules are more complicated when unsigned operands are...
|
by: Jorge Peixoto |
last post by:
In the answer to question 12.42 of the C FAQ, we have this code:
putc((unsigned)((s.i32 >24) & 0xff), fp);
putc((unsigned)((s.i32 >16) & 0xff), fp);
putc((unsigned)((s.i32 >8) & 0xff), fp);...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |