473,624 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

socket.inet_ato n () in python

4 New Member
please try to help me out with this one....

i am reading IP addresses from command line I need to convert them into their decimal equivalents...a nd priint them

i have to use the socket.inet_ato n() function right ?

but i am not able to print the converted value...

like i am trying the code as

print "decimal equivalent is = %d " %(socket.inet_a ton(sys.srgv[0]))

but this doesnt print anything .... jsut the string written in the print statement is being displayed....
May 21 '10 #1
1 4562
dwblas
626 Recognized Expert Contributor
Check your spelling
print "decimal equivalent is = %d " %(socket.inet_a ton(sys.srgv[0]))

And I would strongly suggest that you print sys.argv[0] to see what you are sending. In the future please add some print statements to your code and at least try to do some debugging yourself. Just a heads up, if you continue to ask this type of question you will get a reputation and no one will answer any of your questions. So your code should be, at the very least
print "sending", sys.argv[0], "to inet"
result = socket.inet_ato n(sys.argv[0])
print "result received =", result, type(result)
print "decimal equivalent is = %d " %(result)
May 21 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3307
by: Nagy László Zsolt | last post by:
Hi Python Gurus! Here is a method I used before to receive data over a socket (with Python 2.2): SELECT_GRANULARITY = 0.1 # 0.1 seconds def readdata(self,length,timeout): res = '' remain = length
0
1303
by: Nagy László Zsolt | last post by:
Hi Python Gurus! Here is a method I used before to receive data over a socket (with Python 2.2): SELECT_GRANULARITY = 0.1 # 0.1 seconds def readdata(self,length,timeout): res = '' remain = length
5
4717
by: Jean-Pierre Bergamin | last post by:
Dear python-Community We are forced to use a quite old simulation software that's based on Modula-2. The idea is now to let this software "talk" to the outside world over a TCP/IP network. Since the program has no possibility to use sockets or other mechanisms to send data over the network we have the idea to let python do the network part and let the simu software communicate with the python script in some other way:
11
6845
by: Mike M | last post by:
Is it possible? In the parent process, I have a socket that binds, listens and then accepts new connections (which creates new sockets in the process). I want to be able to pass some of these new sockets to a spawned process. Is it possible, and if so how? Any help is much appreciated!! Mike
3
4836
by: David Bear | last post by:
I found this simple recipe for converting a dotted quad ip address to a string of a long int. struct.unpack('L',socket.inet_aton(ip)) trouble is when I use this, I get struct.error: unpack str size does not match format I thought ip addresses were unsigned 32 bit integers.
4
5051
by: Andrew | last post by:
Hi Are these functions (inet_ntop(), inet_pton()) from the socket library supported on Windows. If not is there an equivalent for them using Windows Ive seen mention of people creating their own in order to use them Appreciate the help
1
3999
by: brad | last post by:
Does Python have an equivalent to C's inet_addr()? Thanks, Brad
1
14706
by: wsguglielmetti | last post by:
Hi, How are you? I'm completly new in python but I know a little of C. I developed a small application in python which generate and receive some data from times in times (question of seconds) and I need to send this data to a unix domain socket (/var/run/sfp) and read the response and print on the screen.
3
9704
by: madsornomads | last post by:
Hi all, I have a problem with reading from a Java server after I have written to it - it just hangs. It works fine if I just write to the server and not try to write. I have read the HOWTO on sockets - and it states that there is a problem (something about flushing), but not what the solutions is. Nor do google. Can somebody please help? A few lines down you can see the example code that sums up the problem. Just change the name of...
0
1053
by: Astan Chee | last post by:
Hi, I have a proxy server that requires authentication on a non-standard port and Im trying to connect to it via socket.connect() I tried doing this: import socket server = ("username:password@proxyaddrs.com",1234) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(server) I keep getting the
0
8174
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.