Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 5th, 2004, 12:07 PM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
Socket Module Implementation

When looking in the socket module code the first comment reads:

Code:
# Wrapper module for _socket, providing some additional facilities
# implemented in Python.


Does anyone know where _socket is?

Also, is it possible to write a lower level socket module?

Reply With Quote
  #2  
Old June 5th, 2004, 12:44 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Under windows i'd assume it were in the DLL folder within Pythons main directory. If you do a search for _socket.pyd then you should find it .

The socket module is a wrapper over that defined by C/C++ so i would highly dout it although if you look into how C/C++ implements this then maybe...

Mark.
__________________
programming language development: www.netytan.com Hula


Last edited by netytan : June 5th, 2004 at 12:47 PM.

Reply With Quote
  #3  
Old June 5th, 2004, 02:57 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,547 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 h 43 m 50 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Quote:
Originally Posted by NetBSD
When looking in the socket module code the first comment reads:

Code:
# Wrapper module for _socket, providing some additional facilities
# implemented in Python.


Does anyone know where _socket is?

Also, is it possible to write a lower level socket module?


socket is a low level socket with blocking

Reply With Quote
  #4  
Old June 6th, 2004, 01:41 PM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
Quote:
Originally Posted by netytan
Under windows i'd assume it were in the DLL folder within Pythons main directory. If you do a search for _socket.pyd then you should find it .


Weird... it doesn't find it?

Reply With Quote
  #5  
Old June 6th, 2004, 01:44 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Mmm, thats strange. Does the socket module import properly. You might also want to try searching for _socket.dll though it should b _socket.pyd by convention.

Mark.

Reply With Quote
  #6  
Old June 6th, 2004, 03:32 PM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
Code:
[Aurora:~] chris% python
Python 2.3 (#1, Sep 13 2003, 00:49:11) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sock = socket.socket()
>>> sock
<socket._socketobject object at 0x538a0>
>>> 


I'm on Mac OS X, so it wouldn't be .dll. I just searched for "_socket" and it found nothing. I downloaded the 2.3.4 source and I can't find it in there either.

Reply With Quote
  #7  
Old June 6th, 2004, 04:22 PM
percivall percivall is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 133 percivall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Let's say you can import _socket (you should be able to):
Code:
>>> import _socket
>>> print _socket.__file__

You should get the implementation file.

Of course, this is nicer and works with many more objects:
Code:
>>> import inspect
>>> import _socket
>>> print inspect.getfile(_socket)

Reply With Quote
  #8  
Old June 6th, 2004, 05:13 PM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
Code:
[Aurora:~] chris% python
Python 2.3 (#1, Sep 13 2003, 00:49:11) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _socket
>>> print _socket.__file__
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/_socket.so


This seems to point me to the shared library. Do you know where I can get the Python source for it (_socket is written in Python, isn't it?)?

Reply With Quote
  #9  
Old June 6th, 2004, 05:20 PM
percivall percivall is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 133 percivall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
No. The _socket module is not written in Python. It's written in C.

You can find the wrapper source in Python-Src/Modules/socketmodule.c and the header file in Python-Src/Modules/socketmodule.h.

Reply With Quote
  #10  
Old June 6th, 2004, 06:33 PM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
Sorry to drag this on longer, but I just need one more clarification: Does socketmodule.c wrap _socket (socket->sockmodule->_socket) or is socketmodule.c the file for _socket?

Bah... I don't even understand how Python can import a C file...

Reply With Quote
  #11  
Old June 6th, 2004, 09:09 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
The better question is - what do you need a lower level socket for?
__________________
Debian - because life's too short for worrying.
Best. (Python.) IRC bot. ever.

Reply With Quote
  #12  
Old June 7th, 2004, 09:53 AM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
For fun?

Reply With Quote
  #13  
Old June 7th, 2004, 11:25 AM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
But what exactly would you need to make it a lower-level one? The socket module provides you pretty much the same control over sockets as the equivalent C socket library would. In other words, they are already fairly low-level in that you have a good amount of control over them, but they are high-level in the respect that they are wrapped in a nice interface that you can easily use without a lot of setup.

Reply With Quote
  #14  
Old June 7th, 2004, 12:49 PM
NetBSD NetBSD is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Canada
Posts: 234 NetBSD Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 25 m 35 sec
Reputation Power: 0
Send a message via MSN to NetBSD
Quote:
Originally Posted by Strike
But what exactly would you need to make it a lower-level one? The socket module provides you pretty much the same control over sockets as the equivalent C socket library would. In other words, they are already fairly low-level in that you have a good amount of control over them, but they are high-level in the respect that they are wrapped in a nice interface that you can easily use without a lot of setup.


I'm interested in low-level stuff (don't tell me to "use C then", because I already do ). Although, it was the actual implementation of the socket module for Python that interested me, and writing it over again would be a waste so the alternative was to write a lower level one.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Socket Module Implementation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread: