Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
bc45a3f8
Kaydet (Commit)
bc45a3f8
authored
Mar 17, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
RFE #567972: Socket objects' family, type and proto properties are
now exposed via new get...() methods.
üst
5c170fd4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
2 deletions
+55
-2
libsocket.tex
Doc/lib/libsocket.tex
+16
-1
socket.py
Lib/socket.py
+18
-0
test_socket.py
Lib/test/test_socket.py
+8
-0
NEWS
Misc/NEWS
+3
-0
socketmodule.c
Modules/socketmodule.c
+10
-1
No files found.
Doc/lib/libsocket.tex
Dosyayı görüntüle @
bc45a3f8
...
...
@@ -626,7 +626,7 @@ timeouts on socket operations.
\end{methoddesc}
\begin{methoddesc}
[socket]
{
gettimeout
}{}
Return
s
the timeout in floating seconds associated with socket
Return the timeout in floating seconds associated with socket
operations, or
\code
{
None
}
if no timeout is set. This reflects
the last call to
\method
{
setblocking()
}
or
\method
{
settimeout()
}
.
\versionadded
{
2.3
}
...
...
@@ -654,6 +654,21 @@ Note that the \method{connect()} operation is subject to the timeout
setting, and in general it is recommended to call
\method
{
settimeout()
}
before calling
\method
{
connect()
}
.
\begin{methoddesc}
[socket]
{
getfamily
}{}
Return the socket family, as given to the
\class
{
socket
}
constructor.
\versionadded
{
2.5
}
\end{methoddesc}
\begin{methoddesc}
[socket]
{
gettype
}{}
Return the socket type, as given to the
\class
{
socket
}
constructor.
\versionadded
{
2.5
}
\end{methoddesc}
\begin{methoddesc}
[socket]
{
getproto
}{}
Return the socket protocol, as given to the
\class
{
socket
}
constructor.
\versionadded
{
2.5
}
\end{methoddesc}
\begin{methoddesc}
[socket]
{
setsockopt
}{
level, optname, value
}
Set the value of the given socket option (see the
\UNIX
{}
manual page
\manpage
{
setsockopt
}{
2
}
). The needed symbolic constants are defined in
...
...
Lib/socket.py
Dosyayı görüntüle @
bc45a3f8
...
...
@@ -183,6 +183,24 @@ class _socketobject(object):
and bufsize arguments are as for the built-in open() function."""
return
_fileobject
(
self
.
_sock
,
mode
,
bufsize
)
def
getfamily
(
self
):
"""getfamily() -> socket family
Return the socket family."""
return
self
.
_sock
.
family
def
gettype
(
self
):
"""gettype() -> socket type
Return the socket type."""
return
self
.
_sock
.
type
def
getproto
(
self
):
"""getproto() -> socket protocol
Return the socket protocol."""
return
self
.
_sock
.
proto
_s
=
(
"def
%
s(self, *args): return self._sock.
%
s(*args)
\n\n
"
"
%
s.__doc__ = _realsocket.
%
s.__doc__
\n
"
)
for
_m
in
_socketmethods
:
...
...
Lib/test/test_socket.py
Dosyayı görüntüle @
bc45a3f8
...
...
@@ -469,6 +469,14 @@ class GeneralModuleTests(unittest.TestCase):
sock
.
close
()
self
.
assertRaises
(
socket
.
error
,
sock
.
send
,
"spam"
)
def
testNewGetMethods
(
self
):
# testing getfamily(), gettype() and getprotocol()
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
assertEqual
(
sock
.
getfamily
(),
socket
.
AF_INET
)
self
.
assertEqual
(
sock
.
gettype
(),
socket
.
SOCK_STREAM
)
self
.
assertEqual
(
sock
.
getproto
(),
0
)
sock
.
close
()
class
BasicTCPTest
(
SocketConnectedTest
):
def
__init__
(
self
,
methodName
=
'runTest'
):
...
...
Misc/NEWS
Dosyayı görüntüle @
bc45a3f8
...
...
@@ -291,6 +291,9 @@ Core and builtins
Extension Modules
-----------------
- RFE #567972: Socket objects'
family
,
type
and
proto
properties
are
now
exposed
via
new
get
...()
methods
.
-
Everything
under
lib
-
old
was
removed
.
This
includes
the
following
modules
:
Para
,
addpack
,
cmp
,
cmpcache
,
codehack
,
dircmp
,
dump
,
find
,
fmt
,
grep
,
lockfile
,
newdir
,
ni
,
packmail
,
poly
,
rand
,
statcache
,
tb
,
tzparse
,
...
...
Modules/socketmodule.c
Dosyayı görüntüle @
bc45a3f8
...
...
@@ -62,6 +62,7 @@ Local naming conventions:
*/
#include "Python.h"
#include "structmember.h"
#undef MAX
#define MAX(x, y) ((x) < (y) ? (y) : (x))
...
...
@@ -2502,6 +2503,14 @@ static PyMethodDef sock_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
};
/* SockObject members */
static
PyMemberDef
sock_memberlist
[]
=
{
{
"family"
,
T_INT
,
offsetof
(
PySocketSockObject
,
sock_family
),
READONLY
,
"the socket family"
},
{
"type"
,
T_INT
,
offsetof
(
PySocketSockObject
,
sock_type
),
READONLY
,
"the socket type"
},
{
"proto"
,
T_INT
,
offsetof
(
PySocketSockObject
,
sock_proto
),
READONLY
,
"the socket protocol"
},
{
"timeout"
,
T_DOUBLE
,
offsetof
(
PySocketSockObject
,
sock_timeout
),
READONLY
,
"the socket timeout"
},
{
0
},
};
/* Deallocate a socket object in response to the last Py_DECREF().
First close the file description. */
...
...
@@ -2625,7 +2634,7 @@ static PyTypeObject sock_type = {
0
,
/* tp_iter */
0
,
/* tp_iternext */
sock_methods
,
/* tp_methods */
0
,
/* tp_members */
sock_memberlist
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment